Skip to main content
Filter by
Sorted by
Tagged with
62 votes
25 answers
109k views

When I clean the android project in android studio, the error happens. I have backed to previous commit or different branch, which worked fine couple days ago, but has this error now. I have checked ...
Xianwei's user avatar
  • 2,561
48 votes
7 answers
44k views

I'm using the JavaCompiler from the javax.tools package (JDK 1.7) to compile some stuff on the fly, like this: compiler.run(null, null, "-cp", paths, "path/to/my/file.java"); It works but I would ...
Sandman's user avatar
  • 2,785
45 votes
3 answers
22k views

I use the class javax.tools.JavaCompiler (jdk6) to compile a source file, but the source file depends on some jar file. How to set the classpath of the javax.tools.JavaCompiler?
Diablo.Wu's user avatar
  • 1,171
39 votes
1 answer
7k views

Maven Compiler Plugin documentation states: The Compiler Plugin is used to compile the sources of your project. Since 3.0, the default compiler is javax.tools.JavaCompiler (if you are using java 1.6)...
Vic's user avatar
  • 22.3k
33 votes
3 answers
14k views

I have found many references explaining how to programmatically compile a Java class using the JavaCompiler class: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); int result = compiler....
Sergio's user avatar
  • 8,670
18 votes
3 answers
10k views

I have been looking for a solution for below requirement - Source files are written with Custom Annotation on a method Method body needs a little variation based on the annotation. Source file should ...
user1128134's user avatar
17 votes
3 answers
15k views

I am trying to write a custom Anntoation processor. The annotation processor will process each class file at compile time to check annotations, But how am i able to get the class that it is currently ...
user1004413's user avatar
  • 2,629
16 votes
3 answers
19k views

Java compiler error: string too large to encode using UTF-8 written instead as 'STRING_TOO_LARGE'. I want to note, that there I have no long string and no one vector drawable that bigger than 32kb (...
Tigran Babajanyan's user avatar
15 votes
5 answers
18k views

I accidentally wrote a java statement with two semicolons at the end. The java compiler does not show any error and it runs. Code: System.out.println("Length after delete the text is "+name.length(...
M.A.Murali's user avatar
  • 10.2k
11 votes
6 answers
15k views

MyClass.java: package test; public class MyClass { public void myMethod(){ System.out.println("My Method Called"); } } Listing for SimpleCompileTest.java that compiles the MyClass....
java_geek's user avatar
  • 18.1k
11 votes
2 answers
8k views

I know you can't change the classpath in Java 9 because I read this: Add jar to classpath at runtime under java 9 I just want to list jar files and folders currently on the Classpath so that I can ...
GlenPeterson's user avatar
  • 5,296
11 votes
2 answers
3k views

I wish to compile source without having the dependencies present on the machine. Example: File A.java: import some.pkg.B; public class A extends B {...} I don't have B source present, I wish to ...
Chen Harel's user avatar
  • 10.1k
10 votes
4 answers
5k views

Hello All I am writing some software that will allow users to create their own Java classes for a specific use in my software package. Obviously, my software will need to be able to invoke a Java ...
Marc's user avatar
  • 3,606
10 votes
2 answers
2k views

I know this has been asked and answered a lot but I still don't have a good solution and I still don't understand some parts. So I have the requirement to compile *.java files programmatically. ...
user2229298's user avatar
9 votes
2 answers
1k views

Suppose a class defines a constant field: public class Foo { public static final int CONSTANT_FIELD = 3; } And suppose an annotation interface is declared like the following: public @interface ...
Sam Harwell's user avatar
9 votes
1 answer
434 views

My application generates java code during runtime and compiles it using the JavaCompiler API. Some of the generated files can be rather large - up to a few hundred thousand lines. I find that when I ...
Jewels's user avatar
  • 1,056
8 votes
1 answer
5k views

I wish to use the Java compiler tree in Eclipse. I have come across the API itself on the Oracle web site here, however I cannot find the JAR file for the library. Am I missing something?!
Joeblackdev's user avatar
  • 7,357
8 votes
1 answer
932 views

We have an app that's been migrated from a traditional WAR Spring web application to what we had hoped would be a modern Spring Boot executable Jar. One of the app modules uses the JavaCompiler API ...
ronif's user avatar
  • 855
7 votes
1 answer
13k views

If I create a custom annotation (example: @SaveFuncName("saveMe") will add a method called saveMe() with some code my processor generates), can the javac compiler use my annotation processor to add a ...
Don Rhummy's user avatar
  • 26.1k
7 votes
1 answer
3k views

I want to use JavaCompiler to dynamically create some classes. I found the source code of the javax.tools package, but there is no implementation; some posts on the internet say it depends on tools....
Brodie's user avatar
  • 605
7 votes
4 answers
3k views

I am writing web app for java learning. Using which users may compile their code on my serwer + run that code. Compiling is easy with JavaCompiler: JavaCompiler compiler = ToolProvider....
tzim's user avatar
  • 1,765
7 votes
1 answer
3k views

I use JDT to compile my java classes. BatchCompiler returns a string but I need an array of problems/errors with their column and row information. compiler.compile(units); prints the error to its ...
burak emre's user avatar
  • 1,601
6 votes
3 answers
7k views

My usage case is compiling generated source files from a java program using the ToolProvider and JavaCompiler classes provided in JDK 6. The source files contain references to classes in the context ...
Phil's user avatar
  • 909
6 votes
1 answer
5k views

Hi I have requirement to create ,compile and load java classes run time. Using FTL i am creating java source files , and able to compile the source if there is no dynamic dependency. To elaborate ...
Satheesh Cheveri's user avatar
6 votes
4 answers
3k views

Is there any tool which provides Java dynamic code generation and that also supports generics? Javassist for example, is the kind of tool that I need, but it does not support generics. I wrote a ...
halfwarp's user avatar
  • 1,800
6 votes
4 answers
3k views

It seems to be impossible to use javax.tools.ToolProvider from a custom classloader as required by Ant or Webstart: https://bugs.java.com/bugdatabase/view_bug?bug_id=6548428 javax.tools.ToolProvider....
Gili's user avatar
  • 90.9k
5 votes
1 answer
4k views

I'm using Eclipse and therefore my class files are stored in "bin" in the project folder. How can I set the JavaCompiler to output compiled classes into this "bin" folder? My code: File fRun = new ...
Arian's user avatar
  • 3,231
5 votes
2 answers
325 views

I am researching for a project that will involve my project to compile simple enough java files. From my research I have decided not to try and build my own compiler as this would just take too much ...
Hip Hip Array's user avatar
5 votes
2 answers
2k views

I got this Java code from another Stack Overflow thread import java.io.*; import javax.tools.JavaCompiler; import javax.tools.ToolProvider; public class Main { public static void main(String[] ...
user969931's user avatar
5 votes
1 answer
1k views

I'm trying to understand JavaCompiler.getTask(). I understand all the parameters except for the second to last one called classes. The Javadoc read: class names (for annotation processing), null ...
Gili's user avatar
  • 90.9k
4 votes
4 answers
11k views

I have a ClassLoader which loads a class compiled by JavaCompiler from a source file. But when I change the source file, save it and recompile it, the ClassLoader still loads the first version of the ...
Arian's user avatar
  • 3,231
4 votes
1 answer
2k views

I was trying to create a class to compile some .java that I'll create at runtime, but I can't get this to work properly. Here's my code File bin = new File(args[args.length-1]); System....
Rafael Palliarini's user avatar
4 votes
1 answer
2k views

In a project I'm currently working on, I need to generate Java classes at runtime. I also need to avoid using reflection when using these classes later on. I've been search for current solutions to ...
halfwarp's user avatar
  • 1,800
4 votes
2 answers
2k views

Is there any way to run program compiled by JavaCompiler? [javax.tools.JavaCompiler] My code: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); DiagnosticCollector<...
tzim's user avatar
  • 1,765
4 votes
1 answer
1k views

In answers to this question, I learned that it is not possible to invoke the Java Compiler in javax.tools from a GAE app. Does this limitation still apply? If so, what are my options for compiling ...
Tony the Pony's user avatar
4 votes
2 answers
2k views

I'm trying a code example that uses javax.tools to compile code that is in a string. The Class.forName results in a ClassNotFoundException. Does anybody know why? I'm using Java 7. import ...
Jochen's user avatar
  • 794
4 votes
1 answer
1k views

I am new to java and I am following this tutorial as it is very informative and explains everything in great detail. At the bottom of the tutorial it explains how a JavaFileManager can be used to ...
flexinIT's user avatar
  • 431
4 votes
3 answers
2k views

I have an existing "Example Webapp" that references "Example Library" using Maven. I'm running Tomcat 7 inside Eclipse 4.3RC3 with the m2e plugin. When I launch Example Webapp on Tomcat inside Eclipse,...
Garret Wilson's user avatar
4 votes
2 answers
328 views

JavaCompiler - How to pass -X options programmatically to the JavaCompiler class?
priya's user avatar
  • 27k
4 votes
1 answer
1k views

Given a Scope, is there a function that can generate a unique variable name such that a variable declaration for the unique name could be inserted in scope and the resulting source code/...
Daniel Trebbien's user avatar
4 votes
2 answers
666 views

I have been trying to compile some Java Classes in a String using java. I have used javax.tools.JavaCompiler to compile the Classes in the Strings. I have made instances of SimpleJavaFileObject by a ...
Bhanuka Yd's user avatar
3 votes
1 answer
6k views

I can create the schema (Descriptors.Descriptor) at runtime dynamically using FileDescriptorProto, also I'm able to serialize and deserialize messages using DynamicMessage. However performance of ...
Boyolame's user avatar
  • 339
3 votes
2 answers
3k views

I am using JavaCompiler of javax.tools to compile some java code and I am trying to use wildcard in my classpath in order to include all the .jar files but I fail. Here is my code: String ...
NikosDim's user avatar
  • 1,548
3 votes
2 answers
2k views

Mac OS x 10.7 grails> !java -version java version "1.7.0_13" Java(TM) SE Runtime Environment (build 1.7.0_13-b20) Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode) grails> !which ...
Alexander Paul Wansiedler's user avatar
3 votes
2 answers
1k views

I want to load a Java version specific JavaCompiler. This is how I take compiler instance currently: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); My aim is to compile a "user Java ...
niranjan_harpale's user avatar
3 votes
1 answer
653 views

I'm trying to compile many files using the Compiler API. Say I have a directory structure .../program +/org +/foo |+ Main.java +/bar + Tools.java Is there any way to discover all ...
Flame's user avatar
  • 2,207
3 votes
1 answer
928 views

I want to have one feature of Java 8 for Java 7: automatic interface implementation generation for method (to avoid performace deficiency due to reflection calls). I know that Java 8 provide the ...
Sergiy Medvynskyy's user avatar
3 votes
1 answer
1k views

Given the source code and the Java version, I need to be able to validate whether or not the code will compile. If the code does not compile, I need to be able to return the errors within the source ...
Lindstorm's user avatar
  • 919
3 votes
1 answer
818 views

I have created program which loads a java(JPanel) file which user chooses.User basically chooses a Java file which gets compiled by JavaCompiler and next generated class file is loaded. But problem is ...
WitVault's user avatar
  • 24.2k
3 votes
2 answers
206 views

Possible Duplicate: On-the-fly, in-memory java code compilation for Java 5 and Java 6 Compiling Java file with code from within a Java file i have a hello world class available in the string of ...
adeel iqbal's user avatar

1
2 3 4 5