|
Download the Java SE Development Kit 7
from Sun. If you are trying to learn Java you shouldn't use an IDE. Otherwise, you learn the IDE instead of learning Java. I generally use the JDK for all of my Java work.
It is possible that once you have installed the JDK, everything will work fine as is.
If you are not one of the lucky ones, you may need to adjust your PATH and CLASSPATH
environment variables. Instructions are included with the JDK and help specific to you can
be obtained at the campfire in the Cattle Drive (java college) forum.
I put all of my stuff into a directory called java (off of my root, C:\, in Windows and
off of my home directory in unix). On my windows machine,
my PATH includes
"C:\jdk6\BIN;C:\jdk6\JRE\BIN".
and
my CLASSPATH is set to
".;C:\JAVA" (notice the dot before the first semicolon)
Here is a program that you can cut and paste to make sure that you have everything set
up correctly. Make sure you put it into a file called HelloWorld.java (case is important!
even on Windows computers):
public class HelloWorld
{
public static void main( String[] args )
{
System.out.println("hello world!");
}
}
Make sure that you paste this into a text editor (like notepad) and not a word
processor. A word processor will stick a bunch of extra formatting text into the file.
Pull up a console (DOS) or terminal window and put the HelloWorld.java file into your
java directory. Make the java directory your current directory. Type
javac HelloWorld.java
and press enter. Remember: case is still very important, even on Windows computers. If
the program compiles without flaw, you will get your command prompt back. Otherwise, go to
the Cattle Drive (java college) forum and tell us what went wrong.
To run your program, type
java HelloWorld
and press enter. You should then see "hello world!" on your screen. If you
don't, post a message on the Cattle Drive (java college) forum.
|