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
    15.9K+ Learners
    4.45  (967)
    Visual Graphics in C
    2 hrs
    Intermediate
    16.4K+ Learners
    4.47  (763)
    Swift Tutorial
    2 hrs
    Beginner
    3.9K+ Learners
    4.49  (182)
    Systematic Inventive Thinking Innovations
    1 hrs
    Beginner
    2.4K+ Learners
    4.51  (136)
    React JS Tutorial
    2 hrs
    Beginner
    66.4K+ Learners
    4.5  (4640)
    Linux Tutorial
    2 hrs
    Beginner
    53.4K+ Learners
    4.48  (4813)
    Functions in Python
    1 hrs
    Beginner
    17.3K+ Learners
    4.51  (932)
    GitHub Tutorial for Beginners
    2 hrs
    Beginner
    19.8K+ Learners
    4.43  (1272)
    Trees in Java
    2 hrs
    Beginner
    8.1K+ Learners
    4.51  (183)