Questions tagged [javacompiler]

javax.tools.JavaCompiler is an interface used to invoke Java programming language compilers from programs. Not to be confused with Javac, which is the Java compiler included in the Java Development Kit (JDK).

Not to be confused with , the Java compiler included in the Java Development Kit (JDK) from Sun Microsystems.

javax.tools.JavaCompiler is an interface used to invoke programming language compilers from programs.

140 questions
1
vote
0 answers

Java code generation at runtime: prevent creation of file "classlist.mf" in the working directory by javax.tools.JavaCompiler

When I run java code similar to this: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); ... CompilationTask task = compiler.getTask(null, javaFileManager, diagnosticCollector, null, null,…
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
1
vote
1 answer

How to point Eclipse to another ECJ (internal compiler)

There is a bug in EJC (Eclipse's internal Java compiler) and I do not want to wait for an official bugfix. Is there way to point an existing Eclipse installation (let's say 4.6) to an ECJ version from 4.7 beta? I know, I could just replace .jar(s),…
Dime
  • 2,041
  • 3
  • 23
  • 29
1
vote
1 answer

How to compile .java with dependencies on runtime?

I have a lot of .java files that need to import another .java file... Something like this: import package.c; public class A { // do whatever that needs package.c } But I only have the package.c.java. When I try to compile Using Java Compiler or…
1
vote
3 answers

How to print class loading pattern for command "mvn compile"?

When we run, mvn compile, compiler picks the classes to load from various jars in classpath. I want to print the list of "class : jar" combination for such class loading. Thank you in advance.
sagar borse
  • 155
  • 1
  • 2
  • 11
1
vote
4 answers

java - Compile code on client side without JDK

I have a question which I'm pretty confused from. I am aware of the differences between Java Runtime Enviroment and Java Developement Kit. I'm writing a program that uses the ToolProvider.getSystemJavaCompiler() method to compile java code from…
NonameSL
  • 1,405
  • 14
  • 27
1
vote
1 answer

How does the java compiler check if all methods in an interface were implemented?

If I declare that my object implements an interface, but fail to implement those methods, when I compile my code, I get a compiler error. How does the java compiler know that I haven't implemented all of the methods of an interface?
kurryt
  • 210
  • 4
  • 10
1
vote
1 answer

Compile and Run java program in linux with path to the .java file and path to external jars

Yesterday I solved a problem with an answer here on stackoverflow. But I ended up with another problem, I will try to be clear: I have a project folder in the /home/demo/Desktop/xlsToCsv/ directory where inside of it is the java file "xlsToCsv.java"…
1
vote
1 answer

Compile and run java program with mutiple external jar files

I have a simple program that uses apache.poi external libraries in order to manipulate excel files. I used eclipse in a windows environment and now I have to compile and run my program on linux with terminal. I searched how to include those jars…
1
vote
2 answers

JavaCompiler gives error when dependent class is being created

I writed a code that generates two class which I write them to buffer and compile them with JavaCompiler. My classes are like this in .java files; public class A{ public A() { } public String toString(){ return "A";} } and public class…
aburak
  • 11
  • 1
1
vote
1 answer

Compiling java file at runtime works on eclipse but doesn't work from an exported runnable jar file

I've tried to compile, at runtime, a .java file from code and everything works fine on eclipse. But when I've tried to export the project, making a runnable jar file and then execute the jar... well, nothing happens. Why it doesn't work from the…
Saverio Java
  • 78
  • 11
1
vote
1 answer

Howto correctly add compiled class files to jar with package structure

I have a prorgam thats generating source code and want to compile this source code during the java-runtime execution like: generateSource() compileSource() I use the JavaCompiler from ToolProvider: ArrayList optionList = new…
Gobliins
  • 3,848
  • 16
  • 67
  • 122
1
vote
1 answer

UnsupportedClassVersionError Unsupported major.minor version 52.0 (unable to load class )

The same war file when deployed on my machine works fine. However on ubuntu 14. and jdk 1.8 on remote server, I keep getting an exception when I deploy it to tomcat using maven. I checked the jdk listed on the remote server: root@li1242-163:~# …
user471450
1
vote
1 answer

Running a compiled java .class file from within java code and capturing output

I'm trying to write a java program with an interface that allows the user to create .java file and compile and run it (essentially a very simplistic IDE). I'm using java swing for the gui and have so far been able to compile a .java file from within…
Alfred Young
  • 397
  • 1
  • 3
  • 15
1
vote
1 answer

Compiler gives warning when adding "query.getResultList()"

When i use query.getResultList(), THE COMPILER gives a warning. My Code is: Query query = entityManager.createQuery("SELECT s.ledger,sum(s.DebitAmt),sum(s.CreditAmt) FROM VouchersDetailsPO as s WHERE s.Ledger='"+ledgerName+"' GROUP BY…
rocky
  • 103
  • 1
  • 3
  • 10
1
vote
1 answer

JavaCompiler compiled class not found

I have used JavaCompiler to compile a class that I generate on the fly. The compile task succeeds. I then try to load the compiled class using Class.forName("MyClass"); and it fails with a ClassNotFoundException. Is there a known issue with doing…
Amir Afghani
  • 37,814
  • 16
  • 84
  • 124