Java - Compile (class file)

Java Conceptuel Diagram


The compilation create a class source.class file from a java source file ie file.

The create class language is called Java - Bytecode (classfile) and can be run on any OS with any java executable (ie Java - Java Virtual Machine (JVM|Java))


javac utility


The javac utility permits to compile a the source file of a class

javac -sourcepath src -d build\classes src\com\gerardnico\

will create the file


To a specific java version

In order to to generate class files compatible with Java 1.4, use the following command line:

javac -source 1.4


Compile within the code, see Java - Dynamic Java code execution (at runtime)


Get the compiler version

To get the version of the target Java image used by javac (ie the java version), you can use javap

From the root directory of your project (normally src/java), execute the following command

javap -verbose com.domain.classname | grep "major"
major version: 52


Java Version Major version
1.2 46
1.3 47
1.4 48
5 49
6 50
7 51
8 52
9 53
10 54
11 55


the java compiler library is located at javase/9/docs/api/javax/tools/JavaCompiler.html. It is javase/9/docs/api/javax/tools/Tool.html (Before the implementation of module in Java 9, bundled in


A tool is a common interface tools that can be invoked from a program.

Add the compiler as dependency (see Maven doc)

Documentation / Reference

Discover More
Card Puncher Data Processing

is a build tool such as make, gnumake, nmake, jam,... without their limitations. is a Java technology-based build tool developed by the Apache Software Foundation (). supplies...
Java Conceptuel Diagram
Java - Bytecode (classfile)

When you compile a program written in the Java programming language, the compiler converts the human-readable source file into platform-independent code in Classfiles (.class) that a Java Virtual Machine...
Simple Class
Java - Class (Definition)

A java/lang/Classclass provides the blueprint for objects; you create an object from a class. All classes are derived from the Object class. A class declaration names the class and encloses the class...
Java Conceptuel Diagram
Java - Dynamic Java code execution (at runtime)

How to create, compile and run Java code at runtime making it a dynamic, scripting language. The below section is showing parts of the whole script highlighting all the steps needed to create and run...
Java Control Panel
Java - Getting Started - Hello World

A little article on the basics of Java. On Windows, the Java Control Panel: Creation of the file as text file. This simple code is composed of: a class HelloWorld a main...
Java Conceptuel Diagram
Java - JavaServer Pages (JSP)

JavaServer Pages technology lets you put: snippets of servlet code directly into a text-based document. A JSP page is a text-based document that contains two types of text: static template...

Share this page:
Follow us:
Task Runner