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
26
votes
4 answers

Why does the compiler state no unique maximal instance exists?

I have the following classes: public class Obj extends BaseModel { public static final String OBJECT = "object"; public Obj(T object) { setObject(object); } public T getObject() { return get(OBJECT); } …
Snekse
  • 15,474
  • 10
  • 62
  • 77
26
votes
21 answers

"Javac" doesn't work correctly on Windows 10

the problem is that I upgraded to Windows 10 and now I'm installing my tools to programming and now that I installed the JDK 7 of Java, when I try to use in the cmd the command: - "javac" The result of this is: "javac" is not recognized as an…
Sadôk
  • 363
  • 1
  • 3
  • 6
25
votes
2 answers

Where do you configure Eclipse Java compiler (javac) flags?

Ex. javac -g ButtMonkey.java Where do you configure the -g flag when Eclipse compiles Java source? (Using Ganymede but I doubt that has changed in later versions so any answer probably helps.) What I need is: -g Generate all debugging…
Mifune
  • 370
  • 1
  • 5
  • 14
25
votes
8 answers

ToolProvider.getSystemJavaCompiler() returns null - usable with only JRE installed?

I am trying to use the JavaCompiler class: http://docs.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html When I call ToolProvider.getSystemJavaCompiler() it returns null. I think this is because I'm using a JRE instead of a JDK. The…
Josh Sobel
  • 1,268
  • 3
  • 14
  • 27
24
votes
3 answers

Compiling (javac) a UTF8 encoded Java source code with a BOM

Hello and thank you for reading my post. My problem is the following: I want to compile a Java source file with "javac" with this file being UTF-8 encoded with a BOM (the OS is WinXP). Below is what I do: 1) Create a file with "Notepad" and choose…
Léa Massiot
  • 1,928
  • 6
  • 25
  • 43
24
votes
2 answers

Overloading a method: both methods have same erasure

I have the following code and it doesn't work: the error both methods have same erasure appears. public class Foo { public static void main(String[] args) { } public void Bar(V value) { } public void Bar(Object value) { …
parsecer
  • 4,758
  • 13
  • 71
  • 140
24
votes
6 answers

Unable to compile using Java 1.7 in Jetbrains Intellij after moving from 1.6 to 1.7 (maven based project)

Using Jetbrains 11.2 project based on a Maven project. Then I required to move to 1.7. I have 1.7 installed , I updated my pom.xml and I can rebuild the whole package using maven okay. I've modified every setting I can see in Intelli Projects…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
23
votes
3 answers

How to set a java compiler in Netbeans

I'm getting into Java7 development and I've added JDK7 into Java Platforms and have selected it in the project properties. But when I'm compiling, I get messages like: warning: java/lang/Boolean.class(java/lang:Boolean.class): major version 51 is…
Uko
  • 13,134
  • 6
  • 58
  • 106
23
votes
1 answer

Optimizations of "+" operand for strings in JDK 17

We know that in JDK8 and below, strings using a plus sign for concatenation will be compiled into StringBuilder for performance optimization, but after JDK9, it will be implemented using the…
Hyrio
  • 231
  • 3
23
votes
6 answers

Compiling java files in all subfolders?

How to compile all java files in all subfolders on Unix, using javac?
aneuryzm
  • 63,052
  • 100
  • 273
  • 488
23
votes
4 answers

javac error: inconvertible types with generics?

There are several other SO questions talking about generics compiling OK w/ Eclipse's compiler but not javac (i.e. Java: Generics handled differenlty in Eclipse and javac and Generics compiles and runs in Eclipse, but doesn't compile in javac) --…
Jason S
  • 184,598
  • 164
  • 608
  • 970
23
votes
2 answers

Why does the Java Compiler copy finally blocks?

When compiling the following code with a simple try/finally block, the Java Compiler produces the output below (viewed in the ASM Bytecode Viewer): Code: try { System.out.println("Attempting to divide by zero..."); System.out.println(1 /…
Clashsoft
  • 11,553
  • 5
  • 40
  • 79
23
votes
5 answers

How to see the compiler output when running javac through an Ant task?

Is there any clearly explained and simple way to see the compiler output when running javac through an Ant task? Here is my javac Ant tag: Here is the only…
sp00m
  • 47,968
  • 31
  • 142
  • 252
23
votes
4 answers

Is it possible to compile class files with the Java 7 SDK which can run on Java 6 JVMs?

Since the public Java 6 SE JRE is getting closer to it's EOL (Nov '12), I'm considering porting my projects from Java 6 to Java 7. This would'nt be a big deal, if Apple would provide a Java 7 JRE for Mac OS X. But since Apple isn't willing to do so,…
t3chris
  • 1,390
  • 1
  • 15
  • 25
22
votes
1 answer

How do I compile a java file that has jar dependencies?

I have a helper lib that I wrote to sit on top of Apache Commons, and when I try to javac it (so that I can make it into a jar) it complains, quite reasonably, that it has no idea what I'm talking about when I make reference to the stuff that's in…
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236