[java] Working with java
I have installed Java 1.4.1 SDK, now I want to work with it(I use windowsXP)
From the command prompt when I write java -version I can see the version is really 1.4.1.
However, I want to compile a program using javac. I saw that where the java SDK was installed, inside a bin library, there is that javac.exe file.
So if I want to compile a java program with javac in the command prompet, I should simply add a path somewhere in windows to the bin library in the SDK?
How do I add that path?
Or should I do something else?
Also, I was recommended to work with JBuilder and eclipse, but for now I want to work using command prompt.
I would appreaciate if you help me with this.
Thanks in advance.
Yeah, you need to the add the location of your SDK to your path. Go to control panel -> system -> advanced tab. Click on the "environment variables" button, you can add it to your path there.
I added a user variable named java with the path of the bin, but when I write path in the msdos I dont see the path to the java bin.
What am I doing wrong?
What am I doing wrong?
It is explained here:
sun tutorial
It is also a great tutorial if you are just learning the language!
link
sun tutorial
It is also a great tutorial if you are just learning the language!
link
Ok, I was able to append the path, compile and run the helloworld application.
Now I have installed eclipse and I try to somehow run the helloworld application in it.
I have created a project, but I am unable to add the already existing file helloworld.java, I can only create new files.
How do I add the homworld.java file into the project? and how do I compile/run the project in eclipse?
The help is a bit confusing.
Now I have installed eclipse and I try to somehow run the helloworld application in it.
I have created a project, but I am unable to add the already existing file helloworld.java, I can only create new files.
How do I add the homworld.java file into the project? and how do I compile/run the project in eclipse?
The help is a bit confusing.
Quote:Original post by The C modest god
I have installed Java 1.4.1 SDK, now I want to work with it(I use windowsXP)
Stop, stop, stop, why are you using 1.4.1? Use 1.5.0 the latest release, it's much better.
BTW if you REALLY have the need of using 1.4.X, it can't be any other, use 1.4.2 the latest release because it's going to have fixes to some security bugs.
I have another question, I can have only one public class in a .java file, right?
So how do I make a public class in one file, to use a public class in another file.
Simply using it doesn't work, because he says he can't find the class. So there is something additional I need to do.
I am working with JBuilder now.
So I have two .java files in my project, one of them uses the public class in the other file.
Also, how do I compile and run these two .java files using javac from MSDOS?
Thanks in advance.
So how do I make a public class in one file, to use a public class in another file.
Simply using it doesn't work, because he says he can't find the class. So there is something additional I need to do.
I am working with JBuilder now.
So I have two .java files in my project, one of them uses the public class in the other file.
Also, how do I compile and run these two .java files using javac from MSDOS?
Thanks in advance.
In DOS:
one way is to have java use the 'default' package, which is simplest. Put all your files in the same directory, run <javac.exe path> *.java while in the directory, then to run, just type <java.exe path> <name of the class with main method>.
If you want to separate your files into packages, your directory structure must match your package structure and you need to put a package statement in your source files, and you need to use the import statement to import your classes.
one way is to have java use the 'default' package, which is simplest. Put all your files in the same directory, run <javac.exe path> *.java while in the directory, then to run, just type <java.exe path> <name of the class with main method>.
If you want to separate your files into packages, your directory structure must match your package structure and you need to put a package statement in your source files, and you need to use the import statement to import your classes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement