Assumption:
- The Java JDK has installed and Java path variable has set.
- You have a Java source code (.java file). In this example, using MyFirstJavaProgram.java source code.
To get MyFirstJavaProgram.java, click Hello World In Java >
Step:
- Open Command Prompt.
- Set the directory in which the .java file is saved. In our case, the .java file is saved in C:\demo.
- Use the following command to compile the Java program.
javac MyFirstJavaProgram.java
and press enter. - Use the following command to run the Java program:
java MyFirstJavaProgram
and press enter. - Or running a Java program using classpath option, which allows you to run a bytecode files in a same directory.
java -cp . MyFirstJavaProgram
and press enter.
< to learn about Open Command Prompt in step 1, click How To Launch Command Prompt
< to learn more about step 2,
- To set or change the current drive to C:\, click Top Command Prompt, read on How To Access The Another Drive.
- If your working path is similar like C:\Users\Administrator , click Change Directory In Command Prompt, read on Set current directory to the root directory of the current drive..
- If you do not have a demo folder, click Top Command Prompt, read on MKDIR, set [Folder] to demo.
- To Set the directory, click Top Command Prompt, read on CD / CHDIR, set [path to folder] to demo\.
Notes:
- Directory does the exact same thing as folder.
- Path does the exact same thing as location or address.
Bibliography:
https://www.mcmaster.ca/ ( university )
https://jenkov.com/
Tidak ada komentar:
Posting Komentar