
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between javac and 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.
Advertisements