Questions tagged [java-compiler-api]

A Java API for the Java compiler, available as javax.tools.JavaCompiler and related classes. (Use [javac] for questions about the command line compiler.)

181 questions
0
votes
1 answer

Javac : ignoring "should be declared in a file named..."

I'm using tools from the compiler API (javax.tools.JavaCompiler) to dynamically generated Java bytecode. I build source code and use API to compile it, then use it via reflexion. That's perfectly fine as long as I only try te generated non-public…
PomPom
  • 1,468
  • 11
  • 20
0
votes
1 answer

Compile Java classes at runtime of Eclipse Plugin

I'm in a very awkward situation here. Im developping an 'Eclipse plugin' that has to 'compile' .java files into .class files (or maybe even a jar). I am trying to use the Java Compiler API in order to do something like this : public class Compiler…
0
votes
0 answers

Set JVM heap space when I use javax.tools.JavaCompiler

I'm using the JavaCompiler APIs to compile some Java source code. However, I'm getting OutOfMemoryError exceptions. I tried to use the -Xmx1G options, but it does not work: java.lang.IllegalArgumentException: invalid flag: -J-Xmx1G at…
user803437
  • 13
  • 2
0
votes
1 answer

CompilationTask.call() introduces ClassNotFoundException. Worked in JDK6, not in JDK7

After moving from JDK6 to JDK7, the next code fails with a ClassNotFoundException CompilationTask task = cSysCompiler.getTask(null, cFileManager, cDiagnosticCollector, null, null, cUnitsToCompile); boolean mSuccess = task.call(); Analyzer mAnalyzer…
Houtman
  • 2,819
  • 2
  • 24
  • 34
0
votes
1 answer

How does namespace works in ant build file?

I'm trying to use ant-contrib and I notice sometime it is used specifying the ac: namespace and sometimes not. When should I use the namespace and why?
Duccio Fabbri
  • 998
  • 1
  • 10
  • 21
0
votes
2 answers

Running java program from another java program

I'm trying to run a Java program from another Java application. Here is my code: public class Main { public static int Exec() throws IOException { Process p = Runtime.getRuntime().exec("javac -d C:/Users/Dinara/Desktop/D/bin " +…
Dinara
  • 523
  • 1
  • 6
  • 9
0
votes
1 answer

Compiling directories with JavaCompiler

I have the following which code which is being used to compile single files with JavaCompiler: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); DiagnosticCollector diagnostics = new…
Jeff Demanche
  • 624
  • 7
  • 25
0
votes
3 answers

Restricting Java Compiler API

I'm thinking of creating an in-game code IDE that uses a more restricted version of Java, for instance I do not want it to use the I/O stream APIs. Is this even possible? Also, inb4 this. It still doesn't help with restricting ability, only…
0
votes
2 answers

Dynamic Compiling Without Create Physical File

I follow the tutorial from Generating Java classes dynamically through Java compiler API, the code is work but what I see is the program will create a class file after compiling it. import java.io.IOException; import java.net.URI; import…
Crazenezz
  • 3,416
  • 6
  • 31
  • 59
-1
votes
3 answers

Get Classes from File

I have a sourcecode and in this source are two classes referenced. Now I want to compile this code via JavaCompiler but therefore I have to first compile the two referenced classes. Is there a better method than reading the file and search for the…
-1
votes
1 answer

Project packages cannot import Java compiler API: ClassNotFoundException / NoClassDefFoundError

I use Java compiler class inside my Spring Boot application as follows: String classStr = "\n" + "import java.util.List;\n" + "import java.util.Map;\n" + "import java.util.Arrays;\n"+ "public class TestClass {\n" +…
-2
votes
1 answer

Interpreter and Compiler

Can any one help me in figuring out what compilers and interpreters are? And what their difference is ? Appreciate it if explained for Java beginner as I am one.
-2
votes
2 answers

How to replace XML with Java?

I don't understand worldwide fashion to use XML for storing settings, page or GUI layouts and even bean sets. If we take into account the fact, that XML is not a single language, but a template to define multiple languages, the mass insanity become…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
-3
votes
1 answer

Online java compiler

I have server which compiles java files. How Can I prevent my server from bad java files. For instance my server shouldn't compile code which deletes all files from server. Os: windows Java version 1.8 C# runner = new Process { …
-4
votes
2 answers

How can compile I `.java file` in jsp?

Using java compiler API I want to compile a java file in jsp. I created a html file and using its textArea element I sent its text, which is expected to be code in java entered by user, to JSP on server and after collecting it in a string I made a…
sony
  • 375
  • 1
  • 6
  • 21
1 2 3
12
13