- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between javac, java commands?
The javac command is used to compile Java programs, it takes .java file as input and produces bytecode. Following is the syntax of this command.
>javac sample.java
The java command is used to execute the bytecode of java. It takes byte code as input and runs it and produces the output. Following is the syntax of this command.
>java sample
Let us consider an example create a Sample Java program with name Sample.java
Sample.java
public class Sample { public static void main(String args[]) { System.out.println("Hi welcome to Tutorialspoint"); } }
If you compile this program using Javac command as shown below -
C:\Examples >javac Sample.java
This command compiles the given java file and generates a .class file (byte code)

And if you execute the generated byte code (.class) file using the java command as shown below -
C:\Sample>java Sample Hi welcome to Tutorialspoint
This command executes the given .class file and produces the respective output.
- Related Articles
- What is the difference between Java and Core Java?
- What is the difference between Java and Java EE
- What is the difference between Java and JavaScript?
- What is the difference between the 'COPY' and 'ADD' commands in a Dockerfile?
- What is the difference between /* */ and /** */ comments in Java?
- What is the difference between >> and >>> operators in Java?
- What is the difference between compositions and aggregations in Java?
- What is the difference between abstraction and encapsulation in Java?
- What is the difference between transient and volatile in Java?
- What is the difference between Serialization and Deserialization in Java?
- What is the difference between System.out.println() and System.out.print() in Java?
- What is the difference between PATH and CLASSPATH in Java?
- What is the difference between ArrayList and LinkedList in Java?
- What is the difference between java method and native method?
- What is the difference between equals and compareTo in Java?

Advertisements