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
22
votes
3 answers

Recompile to *.Jar After decompile and fix the code?

I have a myfile.jar file. I use jd-gui to decompile all *.class in a folder in myfile.jar. I get many *.java files in many folders After fixing some code in some *.java, now I would like to recompile all *.java back to *.class, and pack the whole…
sandy
  • 251
  • 1
  • 2
  • 3
22
votes
1 answer

Is there a way to improve multicore / multiprocessor performance of the Java compiler?

My coworker noticed that when javac is compiling it only utilizes a single core. Is there anything like the -j command with the gcc for Java that will allow us to distribute the compiler workload across cores or processors? If not, do you think that…
Elijah
  • 13,368
  • 10
  • 57
  • 89
22
votes
3 answers

Troubleshoot slow compilation

What should I do to investigate and troubleshoot a slow compilation problem? My project has about 100 classes and takes more than 45 seconds to compile, which seems very slow to me. As a reference, I have another project with 50 classes that…
assylias
  • 321,522
  • 82
  • 660
  • 783
22
votes
1 answer

Why do lambdas in Java 8 disallow forward reference to member variables where anonymous classes don't?

The following class contains a member variable runnable which is initialized with an instance of an anonymous inner class. The inner class references the same member: class Example { Runnable runnable = new Runnable() { @Override …
Feuermurmel
  • 9,490
  • 10
  • 60
  • 90
22
votes
13 answers

Maven: WARNING Unable to autodetect 'javac' path, using 'javac' from the environment

When running Maven, I get this output: [WARNING] Unable to autodetect 'javac' path, using 'javac' from the environment. How do I fix this?
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
22
votes
3 answers

How to compile multiple Java files when there are Java files in other packages?

I am compiling multiple files in a directory (javac *.java) but I have a problem when I try to do this. I get compile errors saying that javac cannot find a symbol of an object. I have multiple packages that contain Java files that are needed to run…
OKGimmeMoney
  • 575
  • 2
  • 7
  • 19
22
votes
2 answers

Where is the source code for the java compiler?

I'm looking for the source code of Sun's standard java compiler, javac. jdk1.6.0_07 has a few classes that are related, but they are interfaces (java.lang.Compiler and javax.tools.JavaCompiler). There's also some packages under com.sun.mirror.* and…
13ren
  • 11,887
  • 9
  • 47
  • 64
22
votes
5 answers

Resolving version conflict between java and javac on Ubuntu

I have a problem with my compiled Java application on Ubuntu. It throws UnsupportedClassVersionError. I am compiling with a higher JDK version than the one that is configured in my PATH to run Java: $ javac -version javac 1.7.0_147 $ java…
xralf
  • 3,312
  • 45
  • 129
  • 200
21
votes
6 answers

Preserving parameter/argument names in compiled Java classes

When I compile something like this: public class MyClass { void myMethod(String name, String options, String query, String comment) { ... } } and compile this to a class file, it seems that argument names are lost. That is, when…
Lena Schimmel
  • 7,203
  • 5
  • 43
  • 58
21
votes
5 answers

Intellij IDEA: "unmappable character for encoding UTF-8" compiling ISO-8859-1 files

I have a mixed-encoding source tree and I'm getting the warning above for some of my source files. I managed to sucessfully set the encoding for those files to ISO 8859-1 and, after invalidating IDEA's caches, they now display correctly in the…
David Moles
  • 48,006
  • 27
  • 136
  • 235
21
votes
1 answer

Why this code compiles with jdk8u45 and above but not with jdk8u25?

Please, could someone help me to figure out why the following code compiles with jdk8u45 and above but fails with jdk8u25? I looked through the JDK release notes but didn't find anything related to the issue or maybe missed it. The code public…
Alex K.
  • 714
  • 4
  • 14
21
votes
6 answers

How to compile java package structures using javac

I am trying to compile (from the command line) a java package that imports another package of my own. I was following a tutorial online but it seems that I get an error when I try to compile the final java file (CallPackage.java). Here is the file…
Pswiss87
  • 725
  • 1
  • 6
  • 16
21
votes
3 answers

IntelliJ says "Warning: java: foo/bar/Baz.java uses unchecked or unsafe operations", but it doesn't say in which line it is referring to

I am getting this warning: When I click on the image, it just opens the associated Editor, but it doesn't say the line number where the warning is raised. I don't want to add @SuppressWarning("unchecked") on the whole class... Any workaround/fix?
21
votes
4 answers

How to increase the error limit of 100 errors on IntelliJ IDEA?

I have an IntelliJ IDEA project but the compilation stops when it does encounter more than 100 errors and I would like to increase the limit in order to figure it out how much I do have to "refactor" the ancient code.
sorin
  • 161,544
  • 178
  • 535
  • 806
20
votes
5 answers

Workaround for javac compilation order bug in maven

I'm encountering a bug in the Java compiler where the order of files submitted for compilation can cause code not to compile. I've drilled down the code to isolate the smallest amount of code I could to reproduce the problem, resulting in three…
Ben Hardy
  • 1,739
  • 14
  • 16