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
0
votes
0 answers

Java Compiler Incorrect Boxed Primitive Coercion

USING: openjdk-11-jdk-headless=11.0.16+8-0ubuntu1~20.04 I have ClassB with a static creation method in a library. public ClassB { public static ClassB create(UUID id, boolean flag); } In another library I have ClassA calling the creation method…
akagixxer
  • 1,767
  • 3
  • 21
  • 35
0
votes
0 answers

Generate Javadoc and sources for the library

I have an Interface and a Class that implements it in a Project (say Project1): public interface MainInterface { /** * some description goes here * @param foo * @param bar * @param ufo */ void someAbstractMethod(int…
0
votes
1 answer

How to make Java compiler ignore the absent interfaces implemented by a dependency class?

I'm modding Minecraft and I imported a mod jar as dependency. However, the compiler prompted error since the class from the dependency mod I invoked method of implemented interfaces from other mods. In my code, I invoked a method of a class from the…
0
votes
1 answer

Problem running AspectJ Load-Time-Weaving with java command

I am trying to run and test the aspectJ load time weaving. It compiled successfully. javac -cp "lib/*" -d classes src/*.java While running the program, the output is only Hello. Sadly, aspect did not run. java…
0
votes
1 answer

"package exists in another module" error when setting up JDK11 source code in Intellij IDEA

I downloaded OpenJDK11 source code and tried to set it up in Intellij IDEA(version 2022.1.3) with JDK correto-11. When I build the project, an error says: "java: package exists in another module: java.base" as shown below. Does anyone have any idea…
aqingsao
  • 2,104
  • 1
  • 19
  • 18
0
votes
1 answer

Issues with jar exporter tool

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\com\starworks\kronos Here is my code so…
Temps
  • 21
  • 6
0
votes
0 answers

Is it possible to get a diagnostic's arguments using the JavaCompiler Interface?

I'm using the JavaCompiler Interface to compile source code files from within a Java program. I've successfully written code that captures the errors that exist in the source code file. I'm now trying to access the arguments of the diagnostic (for…
Janewby21
  • 1
  • 1
0
votes
0 answers

java modularization compile, multiple modules but spring can scan all same package name model to load spring context

enter image description here with this scene, spring can scan all modules annotation(@Service & @Mapper....) so, I know the java has two section compilation, pre-compile and JIT(AOT)compile, When java programs running, JVM will find path by class…
0
votes
0 answers

How to compile Java 9 and subsequent releases code in JDK8?

I have a maven aggregate project that contains api, application, domain, infrastructure and common-util modules. The aggregate project JDK version is 17, but the common-util module alone uses JDK8 instead of 17 (for more compatibility). All source…
0
votes
1 answer

ClassCastException when compiling, loading and using inherited class at runtime

I am trying to compile, load and use an inherited class at runtime. Here is the structure of my Java/Maven project. Note there are no .java files under com.mycompany.model.inherited. This is where generated class files will be placed. src/main/java …
Dili
  • 556
  • 1
  • 5
  • 14
0
votes
0 answers

Compiler cannot detect wrong generic type

Consider below code snippet List doubles = new ArrayList(List.of("1")); doubles.add(1.0); for (Double item: doubles) { System.out.println(item.intValue()); } Java compiler fails to detect the wrong type in ArrayList and causing runtime…
HKIT
  • 628
  • 1
  • 8
  • 19
0
votes
2 answers

Get Resource in openjdk 11

Classx.class.getResource("/com/sun/java/swing/plaf/windows/icons/ListView.gif"); Classx.class.getResource("/javax/swing/plaf/metal/icons/ocean/expanded.gif"); How can I get resource on JDK 11, which is working on JDK 8? I have tried getClass(),…
Samir
  • 1
  • 2
0
votes
0 answers

JavaCompiler class can not find imports upon compiling

I need to dynamically compile a class, which uses certain imports. To compile it I use the JavaCompiler class: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); compiler.run(null, null, null, classPath); I am trying to compile a class…
Zylesto
  • 1
  • 4
0
votes
1 answer

Compiling and running java project with many dependencies classes in other directories

I have this structure of all my directories: I am trying to compile and execute ServerMain and ClientMain. The following compilation worked: src>javac -cp .;../lib/gson-2.8.2.jar client/gui/*.java client/net/*.java client/*.java server/*.java…
0
votes
0 answers

How does Java resolve file pathname when the project is compiled?

In my source code, I created a Java File object pointing to a static image file with the pathname src/a/b/c/img.jpeg. When the project is built, I did not see the static image file included in the build directory. When I execute the program - how…
Hans
  • 63
  • 1
  • 5