Run my "HelloWorld"
Don't ask me why I review such easy a question. You know, it is really important for me to remember everything I have learned and used before.
In fact, when I opened the website of sun and try to find JDK, I felt very suprise that the newest version of JDK is 6, and the preview document of 7th version has come out. And when I learned Java 3 years ago, I was using JDK 1.4.1. On my goodness.
Ok, let's begin our note.
First of all, we need to install JDK and set up the enviroment variables.
for “Path", we need to add the address of javac.exe and put a semicolon after it.
for classpath, the easiest way is add ".\"for it.
After that, we could start to write our program.
The oldest and easiest way ot writing a Java program is using the Notepad.
Create a file with the same name of the class, for example, HelloWorld.java. Make sure to capitalize the same characters in both the file name and the class name.
public class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello!");
}
}
When compile it, open the DOS-Mode and come into the directory of the class we create and use command "javac" to compile it.
javac HelloWorld.java
If nothing comes out except a blank line, that means everything goes ok and the file "HelloWorld.class" has been generated.
and then run the class:
java HelloWorld
then the String "Hello" should be shows out.
If not, please check the eviroment variables. What I should mention is we run it with "java HelloWorld" but not "java HelloWorld.class" and that also means we never use .class during the process of our programming.
I've download the Eclipse on my computer and I'll try to use it tomorrow.
阅读(1271) | 评论(0) | 转发(0) |