[RESOLVED] Dependencies of class files

Answered

Hello, is it always possible to use a library of class files instead of jar files in the recent releases ?

In IntelliJ 2020 i have not problems with that, but since the last year whenever i try a new release i can't even compile a Hello World application without use my library in the form of a jar file (module not found exception with 'requires mymodule' in module-info).

When you indicate dependencies for your project, IntelliJ create always a --classpath option in the command line, with witch you can target directories of class files, thus i don't understand why it doesn't work anymore...

4 comments
Comment actions Permalink

Hello,

Is it possible to provide project example for investigation?

0
Comment actions Permalink

Sorry for the delay.

The project structure is :

HelloWorld > src > helloworld > main > Main.java

HelloWorld > src > helloworld > module-info.java

The main class :

package helloworld.main;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;



public final class Main extends Application
{
@Override
public void start(final Stage stage)
{
stage.setScene(new Scene(new StackPane(new Text("Hello World")), 300, 150));
stage.setTitle("Hello World");
stage.show();
}


public static void main(final String[] args)
{
launch(args);
}
}

The module-info file :

module helloworld
{
requires javafx.base;
requires javafx.graphics;
requires bb.base;
exports helloworld.main to javafx.graphics;
}

javafx.base, javafx.graphics and bb.base are global libraries in the dependencies of the hellloworld module.

bb.base is a global library module located in "home/brice/Documents/Code/Java/lib/class/bb/bb.base", a directory which contains the module-info.class file.

The command line is:

/home/brice/Bin/jdk/18/bin/java -javaagent:/home/brice/Bin/idea/22/lib/idea_rt.jar=39555:/home/brice/Bin/idea/22/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /home/brice/Documents/Code/Java/lib/class/bb/bb.base -p /home/brice/Bin/javafx/17/lib/javafx.base.jar:/home/brice/Bin/javafx/17/lib/javafx.graphics.jar:/home/brice/Documents/Développement/Java/HelloWorld/out -m helloworld/helloworld.main.Main

And the error is :

Error occurred during initialization of boot layer
java.lang.module.FindException: Module bb.base not found, required by helloworld
0
Comment actions Permalink

Does it work from command line outside IDE?

0
Comment actions Permalink

I always forgot to test the command line separetly; no it doesn't work, but when i add the /home/brice/Documents/Code/Java/lib/class/bb/bb.base path in the -p section without changing anything else, yes.

Thus inside the IDE, the VM options in the configuration dialog must be modified, otherwise the default behavior block.

Thank you.

0

Please sign in to leave a comment.