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.4K+ Learners
    4.44  (1050)
    Visual Graphics in C
    2 hrs
    Intermediate
    17K+ Learners
    4.49  (851)
    Swift Tutorial
    2 hrs
    Beginner
    4K+ Learners
    4.49  (199)
    Systematic Inventive Thinking Innovations
    1 hrs
    Beginner
    2.5K+ Learners
    4.52  (157)
    React JS Tutorial
    2 hrs
    Beginner
    68.9K+ Learners
    4.5  (5211)
    Linux Tutorial
    2 hrs
    Beginner
    56.1K+ Learners
    4.47  (5602)
    Functions in Python
    1 hrs
    Beginner
    18K+ Learners
    4.46  (1136)
    GitHub Tutorial for Beginners
    2 hrs
    Beginner
    20.8K+ Learners
    4.45  (1480)
    Trees in Java
    2 hrs
    Beginner
    8.3K+ Learners
    4.54  (241)