Skip to main content
Stack Overflow for Teams is now Stack Internal: See how we’re powering the human intelligence layer of enterprise AI. Read more >
Filter by
Sorted by
Tagged with
0 votes
1 answer
471 views

Settings I'm using JDK 22: openjdk version "22" 2024-03-19 OpenJDK Runtime Environment (build 22+36-2370) OpenJDK 64-Bit Server VM (build 22+36-2370, mixed mode, sharing) I'm also using ...
Yann-Gaël Guéhéneuc's user avatar
0 votes
1 answer
138 views

I am working with javax.tools.JavaCompiler, using it to programmatically compile Java code from my running Java application. Everything is working great, except that I don't how to execute the ...
davidalayachew's user avatar
0 votes
0 answers
178 views

Top of the morning/noon/evening! I have a multi project setup in which I use an annotation processor. This annotation processor is supposed to pickup Plugin instances (a custom interface) during the ...
Thorben Kuck's user avatar
  • 1,142
1 vote
0 answers
608 views

I am trying to connect to SSH (Unix environment) using the JSch library in JavaCompiler API. I can connect to the unix environment through a normal Java program but cannot from JavaCompiler API. Looks ...
Sudhanshoo Sarage's user avatar
0 votes
0 answers
96 views

I want to modify some java classes bytecode during/after compilation phase, but before packaging, in order to use custom invokedynamic bootstrap methods. In order to do so, I have written a Java ...
Mikhas's user avatar
  • 882
0 votes
0 answers
82 views

Given the following class hierarchy public AClass { String getSomething() { ... } } public BClass extends AClass { @Override @CustomAnnotation String getSomething() { super.getSomething(); ...
zsz's user avatar
  • 1
0 votes
1 answer
25 views

I am attempting to write a Java project, which will compile any Java project and export a *.jar file. The program expects 3 runtime arguments, which I am specifying as: C:\dev\Kronos\Kronos vendor src\...
Temps's user avatar
  • 21
0 votes
2 answers
192 views

I have scanned the maven directory (.m2) and have filtered all the files ending with .jar. List<File> jarFiles = scanRecursivelyForJarObjects(mavenRepository, fileManager); I am trying the copy ...
vrn's user avatar
  • 159
0 votes
0 answers
647 views

I'm developing a compiler plugin for Javac. My codebase uses preview features, so I need to run using the flag --enable-preview. I can compile my code perfectly using maven, but when I try to do the ...
Auties01's user avatar
2 votes
1 answer
107 views

I'm working on a Maven project that injects and runs some tests in another Maven projects. I already managed to inject them, however, I'm struggling to programmatically compile the other Maven project ...
OBezzad's user avatar
  • 144
-1 votes
1 answer
139 views

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" + ...
Nilanka Manoj's user avatar
1 vote
0 answers
155 views

I am using JavaCompiler API to compile a string representation of an existing java class in a Maven project. Yet, I'm getting a linker error due to internal dependencies and I'm not sure how to ...
OBezzad's user avatar
  • 144
0 votes
2 answers
503 views

How to get parent tree node from JCTree (com.sun.tools.javac.tree.JCTree) in Java? For example: public class MyTreeTranslator extends TreeTranslator { @Override public void visitMethodDef(...
Guo's user avatar
  • 1,823
1 vote
1 answer
94 views

In a tomcat server, at run time, I am reading java class files and compiling them dynamically using the InMemoryJavaCompiler library which internally uses JavaCompiler . Code Sample - ...
Sruts's user avatar
  • 88
0 votes
0 answers
215 views

I'm using JavaCompiler API in Spring boot application. But currently I'm facing with an issue on getting spring boot runnable jar file classpath using System.getProperty("java.class.path") ...
Daniyar's user avatar
  • 886
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
  • 909
1 vote
0 answers
117 views

How do you create a JavaCompiler instance not on your system? More specifically, I would like to be able to create a JavaCompiler instance from a version number. The only techniques I have seen for ...
Lindstorm's user avatar
  • 909
1 vote
1 answer
189 views

I'm writing a Java compiler plugin to add a simple class named MyClass in some classes of my project (something like lombok does). I've managed to do it by writing the code bellow (you can find the ...
bubbles's user avatar
  • 2,727
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
2 votes
0 answers
137 views

I have this unusual (I think?) situation public abstract class Base { public Base() { // code } public final void executeAll() { final Foo foo = new Foo(); final Bar bar ...
Vento's user avatar
  • 91
2 votes
0 answers
320 views

I have developed an application that generates Java source at runtime from an external source. The generated source code implements an interface residing in say org.foo and also calls other classes ...
eddy's user avatar
  • 91
0 votes
1 answer
465 views

I'm looking for a way to detect if a class is inherited from another class/interface in annotation processor. Since the annotation processor runs on the source code not runtime, there's no way to use ...
user1079877's user avatar
  • 9,448
0 votes
1 answer
122 views

Adapting this the following code takes a class and function name, a string of Java code, compiles the code and runs the function. public class Compile { static void compileAndRun(final String ...
user avatar
0 votes
0 answers
196 views

I'm making a several performance tests of different languages. When I started test Java applications I got a problem: JIT Compiler. I noted that after several executions of a method, this method ...
Augusto's user avatar
  • 4,283
1 vote
1 answer
46 views

Just verified that javac compiles every reference or import that it sees, such as JavaDoc @link references. Can this be turned off with an argument? And/or, can a less eager compile be implemented ...
Jonas N's user avatar
  • 1,787
0 votes
0 answers
195 views

I'm creating a file dynamically on execution of an api, Code for it looks like: StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnosticsCollector, null, null); fileManager....
Neo's user avatar
  • 5,228
1 vote
0 answers
116 views

I'm trying to generate some repositories at runtime for spring data jpa with OpenHFT to reduce boilerplate code. The problem is, when running with IDEA it goes just fine, however if i run it in ...
gtBacteria's user avatar
0 votes
1 answer
83 views

I am using JavaCompiler to compile Java code at runtime. For most part, it works well. There are no exceptions during compiling, it works well. I require it to compile a class with @Entity annotation. ...
Vicrum's user avatar
  • 1
-2 votes
1 answer
204 views

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.
Amanuel Getachew's user avatar
1 vote
1 answer
281 views

I have a rather specific problem with the Java Compiler API. For my Usecase I have to generate, compile and load a java-class at runtime in my Web-Application (using Tomcat). In order to do that, I ...
Jo_Nathan's user avatar
2 votes
1 answer
2k views

In a Spring Boot app I'm doing the following at runtime: Generating a Java class Compiling it Accessing some static fields of the compiled class using reflection. I've based my code on this post and ...
forhas's user avatar
  • 12k
1 vote
1 answer
315 views

I'm using JavaCompiler to compile .java code. It works for me while running the class compiled using URLClassLoader to load remote jars. But not work while compiling. Tried to use options like ...
Jiruffe's user avatar
  • 57
1 vote
0 answers
784 views

We have a situation where we are using some library and we would like to customize the logic of a tiny private method used in the library. Unfortunately, the library isn't well written to be extended. ...
Oleksandr's user avatar
  • 3,794
-1 votes
1 answer
49 views

I'm trying to use java compiler api. First I've got "mytest.java" which runs well. Then I have this code: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); ...
Hind Forsum's user avatar
  • 10.7k
0 votes
1 answer
152 views

I am trying to write an extended Java Compiler that gives all the errors and warnings from javac plus some errors for custom unsupported java features. Since this is going to run on a server, i would ...
dj_rydu's user avatar
  • 128
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
0 votes
0 answers
1k views

I have a task to compile java source file from source code. So I used JavaCompiler API. My java class annotated with Lombok annotation @Data. But when I compiled class exceptions are thrown. Name....
sadia's user avatar
  • 325
2 votes
1 answer
571 views

I am dynamically compiling Java sources using the Java compiler API. My generated source files inherit from com.example.BaseClass, which is just a normal class, not dynamically generated. The ...
eddy's user avatar
  • 91
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
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
0 votes
1 answer
464 views

I already have a program that uses JavaCompiler api for compiling Java code at runtime. Can I use the same compiler for scala code? If not, what is the best way to compile scala code in a Java program?...
user9024779's user avatar
0 votes
1 answer
684 views

I am working on a web project where I create a custom .java-File, load it with a custom ClassLoader, compile it using the Compiler API and then execute it via Reflection. The only thing that doesn't ...
Jo_Nathan's user avatar
2 votes
2 answers
311 views

//Following is Hello.java file. public class Hello{ public static void main(String... s){ System.out.println("hello world"); } } I'm trying to compile the above class using Java ...
Abhishek Mishra's user avatar
1 vote
0 answers
89 views

When I run java code similar to this: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); ... CompilationTask task = compiler.getTask(null, javaFileManager, diagnosticCollector, null, null, ...
Geoffrey De Smet's user avatar
1 vote
2 answers
196 views

I am working on a school project where I need to generate Java code that adheres to the Java Language Specs. So far I have been able to generate the Java code randomly which has valid syntax that ...
adarsh hegde's user avatar
  • 1,383
8 votes
1 answer
931 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
2 votes
0 answers
268 views

I'm trying to use JavaCompiler to compile a Java source at runtime: $ cat src/main/java/App.java import java.util.LinkedList; import javax.tools.JavaCompiler; import javax.tools.JavaFileObject; ...
Idan Arye's user avatar
  • 12.7k
3 votes
0 answers
222 views

I'm trying to understand how default JavaCompiler implementation, the one you can get by invoking ToolProvider.getSystemJavaCompiler(). How do you use it with a JavaFileManager? I understand that ...
nadavgam's user avatar
  • 2,516
2 votes
1 answer
2k views

I am learing Java Compiler API recently and I write some code that can compile one simple java source code file into a class file, but it can't compile a source code file which refer another class in ...
kk17's user avatar
  • 631
0 votes
0 answers
54 views

I am learing Java Compiler API recently and I write some code that can compile one simple java source code file into a class file, but it can't compile a source code file which refer another class in ...
kk17's user avatar
  • 631

1
2 3 4 5