Questions tagged [javac]

javac is the primary Java compiler, included in the Java Development Kit (JDK) from Sun Microsystems (now Oracle), and also in versions from other vendors.

javac is the primary Java compiler, included in the Java Development Kit (JDK) from Sun Microsystems (now Oracle), and also in versions from other vendors.

The compiler accepts source code conforming to the Java language specification (JLS) and produces bytecode conforming to the Java Virtual Machine Specification (JVMS). javac is itself written in Java. The compiler can also be invoked programmatically.

2304 questions
770
votes
1 answer

Why does array[idx++]+="a" increase idx once in Java 8 but twice in Java 9 and 10?

For a challenge, a fellow code golfer wrote the following code: import java.util.*; public class Main { public static void main(String[] args) { int size = 3; String[] array = new String[size]; Arrays.fill(array, ""); for(int i =…
Olivier Grégoire
  • 28,397
  • 21
  • 84
  • 121
404
votes
7 answers

ant warning: "'includeantruntime' was not set"

I receive the following warning: [javac] build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds What does this mean?
user496949
  • 75,601
  • 138
  • 297
  • 413
371
votes
16 answers

Error:java: invalid source release: 8 in Intellij. What does it mean?

Im trying to compile some code in I'm using Intellij Ultimate 13.1.4, but I get the following error and I have no idea what it means: Information:Using javac 1.7.0_55 to compile java sources Information:java: Errors occurred while compiling module…
David says Reinstate Monica
  • 16,634
  • 19
  • 69
  • 108
273
votes
6 answers

javac is not recognized as an internal or external command, operable program or batch file

I am experiencing an error while trying to compile Java programs. I am on Windows (this is a Windows-specific problem) and I have the latest JDK installed. I have attempted a solution involving the PATH variable, but the error persists. Console…
user987137
  • 2,747
  • 2
  • 12
  • 3
220
votes
9 answers

In which language are the Java compiler and JVM written?

In which languages are the Java compiler (javac), the virtual machine (JVM) and the java starter written?
Rahul Garg
  • 7,950
  • 8
  • 30
  • 28
209
votes
4 answers

Why does a Java class compile differently with a blank line?

I have the following Java class public class HelloWorld { public static void main(String []args) { } } When I compile this file and run a sha256 on the resulting class file I get 9c8d09e27ea78319ddb85fcf4f8085aa7762b0ab36dc5ba5fd000dccb63960ff…
KNejad
  • 2,011
  • 2
  • 10
  • 21
206
votes
4 answers

What is the difference between javac and the Eclipse compiler?

Is Eclipse's Java compiler just a wrapper around the same core that the javac program is wrapped around, or is it a separate compiler altogether? If the latter, why would they reinvent the wheel?
Bart van Heukelom
  • 40,403
  • 57
  • 174
  • 291
149
votes
4 answers

Does the 'java' command compile Java programs?

Most websites on the internet say: "use the javac command to compile a .java file. Then run it using the java command" But today I tried to run a java program without javac and I got a strange result. Here are the contents of a file called…
milad
  • 1,658
  • 1
  • 6
  • 20
143
votes
7 answers

How to add -Xlint:unchecked to my Android Gradle based project?

I tried to add the following to the root build.gradle file: subprojects { gradle.projectsEvaluated { tasks.withType(Compile) { options.compilerArgs << "-Xlint:unchecked -Xlint:deprecation" } } } But I'm getting…
rfgamaral
  • 15,937
  • 49
  • 156
  • 269
142
votes
9 answers

javac option to compile all java files under a given directory recursively

I am using the javac compiler to compile java files in my project. The files are distributed over several packages like this: com.vistas.util, com.vistas.converter, com.vistas.LineHelper, com.current.mdcontect. Each of these packages has several…
user496934
  • 3,406
  • 9
  • 39
  • 51
135
votes
17 answers

javac not working in windows command prompt

I'm trying to use javac with the windows command prompt, but it's not working. After adding the directory "C:\Program Files\Java\jdk1.6.0_16\bin\" to the end of the PATH environment variable, the java command works fine, but using javac gives me the…
Domenic
  • 3,552
  • 8
  • 29
  • 40
121
votes
11 answers

javac : command not found

I have installed java in my CentOS release 5.5 machine using the command yum install java. But I am unable to compile a class using javac. Do I need to install any other package? I have tried to locate the javac executable but i am unable to locate…
Bikash Barman
  • 1,229
  • 2
  • 9
  • 4
120
votes
13 answers

javac error: Class names are only accepted if annotation processing is explicitly requested

I get this error when I compile my java program: error: Class names, 'EnumDevices', are only accepted if annotation processing is explicitly requested 1 error Here is the java code (I'm running this on Ubuntu). import jcuda.CUDA; import…
user513164
  • 1,608
  • 3
  • 19
  • 25
103
votes
2 answers

What is the --release flag in the Java 9 compiler?

Java 9's javac has a new flag --release: > javac --help ... --release Compile for a specific VM version. Supported targets: 6, 7, 8, 9 How is it different from -source and -target flags? Is it just a shortcut for -source X -target X?
ZhekaKozlov
  • 29,055
  • 16
  • 100
  • 138
95
votes
11 answers

Is the creation of Java class files deterministic?

When using the same JDK (i.e. the same javac executable), are the generated class files always identical? Can there be a difference depending on the operating system or hardware? Except of the JDK version, could there be any other factors resulting…
mstrap
  • 15,236
  • 6
  • 50
  • 77
1
2 3
99 100