Java Help  | |
October 22nd, 2004, 06:56 PM
|
#1 (permalink)
| | Ultimate Member
Join Date: Jul 2003
Posts: 1,253
|
I got all these simple little Java programs I have been making, but how do I allow other people to use this? Like how do I make it into an actual program or how can I make it into an applet so people with the plug-in can use it?
I'm using JCreator and making some basic equation solver problems. |
| |
October 22nd, 2004, 07:13 PM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Pasadena, CA
Posts: 2,177
|
Converting a program into an applet can be pretty easy actually. Depending upon how you set your program up it is sometimes as simple as changing the main method to the init method. You also have to import the correct applet classes.
Wrapping the java classes up into a JAR file also makes it simple for other users to use. If you pack the JAR with the correct commands then it can be executable as well  Remember tho they user MUST have the proper JRE! I remember creating a java applet in v1.4 and people with anything lower than the 1.4 JRE could not view it. Just something to think about.
__________________
YAH! I knew you'd be jealous
Last edited by Tekk : October 22nd, 2004 at 07:15 PM.
|
| |
October 22nd, 2004, 07:37 PM
|
#3 (permalink)
| | Member
Join Date: Sep 2004 Location: Your living room...
Posts: 417
|
I would recommend you use Eclipse if you're going to be doing serious development.
If you're just wanting to do something on the command line, I'd first advise using something other than Windows (just a personal bias  ). The command you're looking for to "compile" is probably something in the realm of: javac filename
__________________
I reserve the right to contradict myself. . .
|
| |
October 22nd, 2004, 07:40 PM
|
#4 (permalink)
| | Ultimate Member
Join Date: Jul 2003
Posts: 1,253
|
Here's a simple program that I made in class for solving the angle using the law of cosine:
//William Rand Dusing
//lawofcosine
import java.text.*;
import java.io.*;
public class lawofcosine
{
public static void main(String[] args) throws IOException
{
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
DecimalFormat output= new DecimalFormat("0.000");
System.out.println("What is the length of one side?");
double side1 = Double.parseDouble(buffer.readLine());
System.out.println("What is the length of the other side?");
double side2 = Double.parseDouble(buffer.readLine());
System.out.println("What is the angle measure in degrees?");
double degrees = Double.parseDouble(buffer.readLine());
double radians = Math.toDegrees(degrees);
double cosradians = Math.cos(radians);
double side3a = (Math.pow(side1,2) + Math.pow(side2,2)) - (2 * (side1) * (side2) * cosradians);
double side3b = Math.sqrt(side3a);
System.out.println();
System.out.println("The side lenght is: " + output.format(side3b));
}
}
What would I do to do what you talked about? |
| |
October 22nd, 2004, 07:44 PM
|
#5 (permalink)
| | Ultimate Member
Join Date: Jul 2003
Posts: 1,253
|
Where do I run javac filename at? I changed the directory to where the file is located in the Command Prompt but it says javac is an invalid command. |
| |
October 22nd, 2004, 07:53 PM
|
#6 (permalink)
| | Leader of the Crab People
Join Date: Oct 2001 Location: NCSU
Posts: 4,381
|
You have to load your java/bin directory into the path first. Basically, javac compiles the program. If you want to share the file, take the compiled byte code (.class file) and give that out. To run the file, simply type java filename (make sure you DO NOT add the .class extension to the filename). The person has to have the JRE installed for that.
You can write a simple batch to run the byte code. Like: Code: @echo off
java lawofcosine Make sure you follow naming conventions too (as my prof. says, you can hear the sound of your tires getting slashed if you don't). Like lawofcosine would be LawOfCosine.
Last edited by Redwolf : October 22nd, 2004 at 07:56 PM.
|
| |
October 22nd, 2004, 07:58 PM
|
#7 (permalink)
| | Ultimate Member
Join Date: Jul 2003
Posts: 1,253
|
Oh ok, I already have the files compiled and now I know how to "open" a program. But cant I "compile" that class file into to a more user friendly exe type file? I just want to be able to click a program icon and it pops up the program. |
| |
October 22nd, 2004, 08:20 PM
|
#8 (permalink)
| | Leader of the Crab People
Join Date: Oct 2001 Location: NCSU
Posts: 4,381
| |
| |
October 22nd, 2004, 09:07 PM
|
#9 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Pasadena, CA
Posts: 2,177
|
Theres also a way to set the proper environment variables in windows to always give you access to the java commands (like javac, java, etc) every time a console is opened up (dos prompt). I forget how to properly set these environment variables but maybe someone on here can remind us
Oh and I forgot to mention that JCreator is a nifty little program! Very fast compared to others I have used (Eclipse, JBuilder 8/9/X, NetBeans). I personally prefer JBuilder because it is a little more robust but it is somewhat of a system hog. JBuilder 8 is very robust as well and I used that all through my college Java classes and its not too much of a sys hog (runs perfect on my XP 2000 with 256MB RAM).
Last edited by Tekk : October 22nd, 2004 at 09:10 PM.
|
| |
October 26th, 2004, 02:23 PM
|
#10 (permalink)
| | Member
Join Date: Sep 2004 Location: Your living room...
Posts: 417
| Quote: |
Originally Posted by Tekk Theres also a way to set the proper environment variables in windows to always give you access to the java commands (like javac, java, etc) every time a console is opened up (dos prompt). I forget how to properly set these environment variables but maybe someone on here can remind us  | Yup, in XP you simply right click "MY COMPUTER" -> "PROPERTIES" -> "ADVANCED" tab -> "ENVIRONMENT VARIABLES" |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |