Похожие чаты

Hello, Java community. I wanted to export my javafx project (openjdk14,

maven) into a jar file using jlink. It requires my project to be modular. In order to make it modular (I use default module, I don't need more modules), I need to create module-info.java
I feel desperate. I tried to create it many times but always get some errors, like "this module does not exist" and other stupid stuff.
I suck at modularity in java.
Any idea how to create module-info.java?

1 ответов

11 просмотров

I don't have experience using jlink directly, but I used a maven plugin for that and it was pretty straightforward to setup: 1. Create module-info.java and compile all your classes to a jar with maven-jar-plugin. 2. Download library jars if there are any (they should be modularized already) with maven-dependency-plugin. 3. Specify what modules you want to be built in the plugin config and where all the jars are located. 4. You get a custom runtime with your program already embedded into it. module-info.java Suppose your sources located under app/src/main/java/com/example/application and your main class is com.example.application.Main. Your module-info.java should be put at app/src/main/java/module-info.java and look like this: module com.example.application { opens com.example.application; exports com.example.application; } If you want to introduce any library dependency, just add requires com.library; there. Honestly, I don't remember the difference between opens and exports, maybe exports is enough. I used opens & exports for a package with my main class, and only exports for all other packages. jlink plugin: https://github.com/moditect/moditect The description says Java 9, but it works fine with later versions. Example configuration: https://pastebin.com/9yFmKi1L

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта