Java - hello world - using JDK only.
The below outlines steps to create and execute a Hello World Java program on a Windows system using just a JDK.
No IDE required, you can create and edit using Notepad or any other text editor.
1. Create a text file (main1.java) with these exact contents:
class MyApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Prints the string to the console.
}
}
2. Save it and compile it to MyApp.class in the command line (open cmd.exe in the same folder where your main1.java is located):
>"C:\Program Files (x86)\Java\jdk1.6.0_26\bin\javac.exe" main1.java
3. The above step created the bytecode file: MyApp.class
4. Run it:
>java -cp . MyApp
Output:
Hello World!
No IDE required, you can create and edit using Notepad or any other text editor.
1. Create a text file (main1.java) with these exact contents:
class MyApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Prints the string to the console.
}
}
2. Save it and compile it to MyApp.class in the command line (open cmd.exe in the same folder where your main1.java is located):
>"C:\Program Files (x86)\Java\jdk1.6.0_26\bin\javac.exe" main1.java
3. The above step created the bytecode file: MyApp.class
4. Run it:
>java -cp . MyApp
Output:
Hello World!
Comments
Post a Comment