After installed of Java environment, it's time to code our first Java program - helloworld.
The first exercise of helloworld we create and compile in "cmd" (DOS Prompt) environment.
- Create a text file helloworld.java, using any editor program you like (notepad or notepad++).
- Entent the code, and save it:
helloworld.java
- Start a "cmd" window in Windows 8, refer to the post "Run 'cmd' in Windows 8" if you don't know how. Change to the directory of helloworld.java.
- Type the command to compile the java program:
javac helloworld.java
- Type the command to run the compiled class:
java helloworld
- If your JDK environment is set properly, the output should be:
Hello World!
*** If you cannot run javac/java due to missing in path setting, refer to the post "Set PATH for JDK 7 on Windows ".
The first exercise of helloworld we create and compile in "cmd" (DOS Prompt) environment.
- Create a text file helloworld.java, using any editor program you like (notepad or notepad++).
- Entent the code, and save it:
1
2
3
4
5
6
7
8
| public class helloworld { public static void main(String[] args) { System.out.println( "Hello World!" ); } } |
helloworld.java
- Start a "cmd" window in Windows 8, refer to the post "Run 'cmd' in Windows 8" if you don't know how. Change to the directory of helloworld.java.
- Type the command to compile the java program:
javac helloworld.java
- Type the command to run the compiled class:
java helloworld
- If your JDK environment is set properly, the output should be:
Hello World!
*** If you cannot run javac/java due to missing in path setting, refer to the post "Set PATH for JDK 7 on Windows ".
0 comments:
Post a Comment