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.

2467 questions
788
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
  • 33,839
  • 23
  • 96
  • 137
411
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
  • 83,087
  • 147
  • 309
  • 426
402
votes
19 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
  • 19,209
  • 22
  • 79
  • 122
294
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,957
  • 3
  • 14
  • 3
252
votes
10 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
  • 8,410
  • 8
  • 33
  • 28
212
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,376
  • 2
  • 14
  • 26
208
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
  • 43,244
  • 59
  • 186
  • 301
160
votes
10 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,822
  • 10
  • 45
  • 64
152
votes
5 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,854
  • 2
  • 11
  • 27
148
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
  • 16,546
  • 57
  • 163
  • 275
138
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…
Dom M.
  • 3,762
  • 8
  • 32
  • 40
136
votes
12 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,788
  • 3
  • 20
  • 26
134
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
  • 36,558
  • 20
  • 126
  • 155
129
votes
12 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,309
  • 2
  • 9
  • 4
98
votes
10 answers

Java: How can I compile an entire directory structure of code ?

The use case is simple. I got the source files that were created using Eclipse. So, there is a deep directory structure, where any Java class could be referring to another Java class in the same, child, sibling or parent folder. How do I compile…
euphoria83
  • 14,768
  • 17
  • 63
  • 73
1
2 3
99 100