Slide 1
Slide 2
Slide 3

compile and run java programming (V2)

No Comments


Download Java: The latest version of Java can be downloaded from the official Oracle website: https://www.oracle.com/in/java/technologies/downloads/
  • To download the JDK file


  • Next, download the JRE file.

  • After clicking, another window will appear where you can click to download the JRE file.


  • After clicking, another window will appear where you can download the JRE file.


  • View the file that has been downloaded:


  •  After downloading, please install it on your computer.
  • Next, we will see the Java folder created in Drive C:\Program Files\Java


  • Example: We have a Java code file named PersonalInfo.java, which has the same name as the class PersonalInfo.
Source Code:
Copied!
  // Personalinfo.java
public class Personalinfo {
    public static void main(String[] args) {
        // Print "Information" to the console
        System.out.println("My name: Him Seanghon");
        System.out.println("Occupation: Teacher");
        System.out.println("Department: ICT_PIKT");
        System.out.println("Institute: PIKT");
    }
}

Watch the video:


  • Step 1: After writing the code, save the file as PersonalInfo.java in the following location:
            C:\Program Files\Java\jdk-23\bin

  •  Step 2: We need to compile it (javac file.java) by executing the following command:
            C:\Program Files\Java\jdk-23\bin>javac PersonalInfo.java

        For (jdk-23), it depends on your installed Java version. After compiling, a file in byte-code format will be created with the same name as the class, having the .class extension — PersonalInfo.class, which is the executable file.

  • Step 3: After successful compilation, we need to run the program (java file) to display the output of our code by executing the following command:
        C:\Program Files\Java\jdk-23\bin>java PersonalInfo

Note: When running the program, do not include the .java or .class extension.

Ebook: https://softkhpc.blogspot.com/2025/05/java-programming-ebooks.html

back to top