The first is from java.sun.com online next JDK (now the version is J2SDK1.4.2), and can be placed in the C: /MYDEV/J2SDK1.4.1_02 after decompression.
Then set environment variables in the system environment variable: plus: java_home = d: /mydev/j2sdk1.4.1_02 plus: javapath =.; D: /MYDEV/J2SDK1.4.1_02/lib/tools.jar Modification: Path is in front Plus D: /MYDEV/J2SDK1.4.1_02/bin; good! Now determine, then restart.
After entering the system, type under the DOS Terminal C: />: Java -Version looks that JDK is already installed successfully. Similar to: Java Version "1.4.1_02" Java (TM) 2 Runtime Environment, Standard Edition (Build 1.4.1_02-B06) Java Hotspot (TM) Client VM (Build 1.4.1_02-b06, mixed mode) is installed!
You can write the program now.
Here is the code of HelloWorldDate.java, your copy code is saved as D: /mywork/helloworlddate.java file. Package com.zmixy;
Import java.util.date;
Public class helloworlddate {public static void main (string [] args) {date date = new date (); system.out.println ("Hello World! NOW IS" DATE);}} ///: ~ End Code.
First at the DOS terminal C: /> CD D: / myworkc: /> d:
Compile command: javac -verbose -d. HelloWorldDate.java will generate COM / ZMIXY / HELLOWORLDATE.CLASS in the current directory
Parameters -verbose: Display all information-D: Specify a path to generating a Class file while generating a package directory (. Representation is in the current directory) (detailed explanation of parameters under C: /> Javac)
Run command: java com.zmixy.helloworlddate (detailed explanation of parameters under C: /> Java)
This is the case that the basic compilation and operation of the Java program is like this. hope it is of help to you.
ZMixy2004 / 03/07