Generated by GPT-5-mini| javac | |
|---|---|
| Name | javac |
| Developer | Sun Microsystems; Oracle Corporation |
| Initial release | 1995 |
| Latest release | Java SE (varies) |
| Written in | C, C++, Java |
| Operating system | Solaris (operating system), Windows NT, Linux, macOS |
| Genre | Compiler |
| License | Oracle binary code license |
javac javac is the primary command-line Java compiler for the Java Platform, developed originally by Sun Microsystems and maintained by Oracle Corporation. It translates Java (programming language) source code into Java bytecode for the Java Virtual Machine used across Solaris (operating system), Linux, macOS, and Windows NT systems. javac forms a core component of the Java Development Kit, alongside tools like jar (computing), javadoc, and java runtime utilities.
javac implements the Java Language Specification's compile-time semantics and produces class files compatible with the Java Virtual Machine Specification. It performs lexical analysis, syntax parsing, semantic analysis, type checking, annotation processing, and code generation to emit bytecode and metadata. As part of the OpenJDK project and historically tied to Sun Microsystems, javac interoperates with the Java Community Process through feature additions in updates to Java SE editions. Its role parallels other compilers such as GCC, Clang, and ECMAScript compilers in translating high-level languages to lower-level representations.
Developers invoke javac from shells provided by Bash (Unix shell), Windows Command Prompt, or PowerShell to compile source files. Typical use compiles files referencing libraries provided in Java Platform, Standard Edition or third-party artifacts from Apache Maven, Gradle (software), or Ivy (dependency manager). It integrates with IDEs like Eclipse (software), IntelliJ IDEA, and NetBeans which orchestrate javac invocations behind GUIs. Continuous integration systems such as Jenkins (software), Travis CI, and GitHub Actions commonly run javac as part of build pipelines that include testing frameworks like JUnit and TestNG.
The compilation pipeline in javac begins with tokenization and parsing according to the Java Language Specification grammar, constructing an abstract syntax tree (AST). Semantic analysis involves symbol resolution, type inference, and annotation processing via the Java Specification Request 269 infrastructure and the javax.annotation.processing API. The intermediate representation is then transformed into Java bytecode consistent with the Java Virtual Machine Specification and serialized into .class files, possibly packaged by jar (computing) for distribution. Optimization phases are limited compared to native compilers like LLVM-based toolchains; runtime optimizations typically occur in the HotSpot JIT compiler at execution time. The tool must account for language features introduced across versions such as those from JDK 1.5 generics, Project Coin enhancements, lambda expressions from JDK 8, and modules from Java Platform Module System introduced in JDK 9.
javac exposes numerous command-line options to control diagnostics, classpath resolution, and output behavior, including -classpath to reference libraries from artifacts produced by Apache Maven repositories, -source and -target to set language and classfile compatibility with specific Java SE releases, and -processor to select annotation processors defined by projects such as Project Lombok. Diagnostic flags integrate with tooling standards from Eclipse (software) and NetBeans for IDE error reporting. Build-time performance can be tuned with options used in tandem with Jenkins (software) agents or Docker containers for reproducible environments. Error and warning management aligns with quality gates enforced by static-analysis tools like FindBugs, SpotBugs, and Checkstyle (tool).
Build systems orchestrate javac to produce reproducible artifacts: Apache Maven executes compilation via lifecycle plugins, Gradle (software) configures toolchains for multi-module projects, and Ant (software) provides tasks calling javac directly. Dependency resolution is often handled by Maven Central, JFrog Artifactory, or Nexus Repository Manager while javac compiles source against resolved jars. Continuous deployment pipelines in Jenkins (software), GitLab CI/CD, and CircleCI commonly run javac alongside packaging via Docker Hub images and deployment to platforms such as Apache Tomcat, WildFly, or GlassFish. Language feature flags and annotation processors are surfaced through plugin configurations for IDEs like IntelliJ IDEA and Eclipse (software).
javac's lineage traces to early Sun Microsystems internal tools created during the development of Java (programming language) in the mid-1990s, evolving through JDK 1.0, JDK 1.1, and subsequent Java SE releases. The tool was reimplemented and open-sourced as part of the OpenJDK project where contributors from Oracle Corporation and community members coordinate via mailing lists and repositories. Design decisions reflect influences from compilers like GCC and frameworks such as ANTLR for parsing strategies. Significant milestones include support for generics specified by JSR 14 and JSR 277 related work, introduction of annotation processing through JSR 269, lambdas via JSR 335, and modularization through Project Jigsaw. The implementation interplays with the HotSpot VM for runtime performance and has been shaped by standards bodies including the Java Community Process and corporate adopters like IBM, Red Hat, and Google that integrate javac outputs into enterprise and cloud platforms.
Category:Java compilers