Selasa, 28 Maret 2023

How To Compile Java 1

 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:

  1. Open Command Prompt.
  2. Set the directory in which the .java file is saved. In our case, the .java file is saved in C:\demo.
  3. Use the following command to compile the Java program.
    javac MyFirstJavaProgram.java
    and press enter.
  4. Use the following command to run the Java program:
    java MyFirstJavaProgram
    and press enter.
  5. 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, 
  1. To set or change the current drive to C:\, click Top Command Prompt, read on How To Access The Another Drive.
  2. 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..
  3. If you do not have a demo folder, click Top Command Prompt, read on MKDIR, set [Folder] to demo.
  4. 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/

Related Post:

Tidak ada komentar:

Posting Komentar