Java

Compiling and Running the Java Program

Compiling and Running the Java Program

Compiling and running a Java program is the first step in learning, especially in java, since this process is a little different than in other languages. The process involves writing source code, compiling it into bytecode, and then running the compiled program. To begin with, all that is required is an editor for writing source code and a command prompt for interacting with the compiler. 
Once written, source code can be saved as. java files which are then fed into the Java compiler from within the command line interface (CLI). This compiles them into class files containing bytecode which can be run on any machine equipped with a JVM (Java Virtual Machine). 
● Compiling: 
Hence to compile the java program, type the following command in CLI: For example, let’s say the file name is FirstProgram.java, you will have to type the following command: 
 

javac FirstProgram.java 


● Running: 
Finally, these compiled applications can be executed by simply typing ‘java’ followed by their name at the CLI and pressing enter - thus completing both the compilation and execution of your program in one step! 
Example: java FirstProgram 

Shortcut: Some IDEs like Eclipse, IntelliJ IDEA, and Netbeans provide a shortcut to compile and run the code by using the "run" button or "ctrl+f11" or "cmd+f11" respectively. 
Hence, once the java code is written, it has to be saved with .java, and then it has to be compiled and executed. 
 

Top course recommendations for you

    Web Scraping with Python
    1 hrs
    Beginner
    16.1K+ Learners
    4.45  (994)
    Visual Graphics in C
    2 hrs
    Intermediate
    16.7K+ Learners
    4.49  (819)
    Swift Tutorial
    2 hrs
    Beginner
    3.9K+ Learners
    4.5  (185)
    Systematic Inventive Thinking Innovations
    1 hrs
    Beginner
    2.5K+ Learners
    4.49  (140)
    React JS Tutorial
    2 hrs
    Beginner
    67.2K+ Learners
    4.5  (4865)
    Linux Tutorial
    2 hrs
    Beginner
    54.4K+ Learners
    4.47  (5101)
    Functions in Python
    1 hrs
    Beginner
    17.6K+ Learners
    4.47  (1047)
    GitHub Tutorial for Beginners
    2 hrs
    Beginner
    20.1K+ Learners
    4.43  (1317)
    Trees in Java
    2 hrs
    Beginner
    8.1K+ Learners
    4.5  (191)