0

Is it possible to create custom Java runtime using jlink from within eclipse IDE for a specific project? If so, how?

I was trying jlink from terminal and was able to build custom Java runtime. However for more complex projects which has multiple module dependencies would be nice if there is an option to create custom java runtime from within eclipse IDE. Something similar to how there is an option to create runnable jar.

srock
  • 403
  • 1
  • 8
  • 17
  • You should probably use a build tool such as [tag:maven] for this sort of thing. You can define maven projects in Eclipse. – greg-449 Jan 05 '22 at 07:43
  • Thanks. I have been reading and trying out this - https://maven.apache.org/plugins/maven-jlink-plugin/usage.html However, in my project I have an application with 1 pom.xml with few dependencies. My application's module-info.java looks like this: `module JavaModuleProject { requires java.base; requires slf4j.api; requires com.pi4j; requires com.rabbitmq.client; }` Now taking above reference websites, what should my pom.xml's tag look like? – srock Jan 05 '22 at 22:26
  • The `` in maven is not the same thing as a Java module. – greg-449 Jan 06 '22 at 08:07
  • Thanks @greg-449. I did some more research. What I'm trying to do now is: 1. creating a runnable jar file for my application (same as before) 2. copied all the dependencies that my application needs i.e. all the jar files which I have added as dependencies in pom.xml into a directory 3. running jdeps on that directory followed by jlink Source: https://levelup.gitconnected.com/java-developing-smaller-docker-images-with-jdeps-and-jlink-d4278718c550 – srock Jan 08 '22 at 01:22
  • However, when I run this for simple logging application it works fine. Get the trimmed down java and can run -jar .jar. But when I try this on a bit more complex (more dependencies) application, I get below error: ``` jdeps --ignore-missing-deps -q --multi-release 15 --print-module-deps --class-path deps/* rpi2.jar > ~/Desktop/jre-deps2.info Exception in thread "main" java.lang.module.FindException: Module java.activation not found, required by java.xml.bind at java.base/java.lang.module.Resolver.findFail(Resolver.java:894) ``` Any clue whats happening. – srock Jan 08 '22 at 01:35
  • The deps directory has below jars (dependencies): `amqp-client-5.12.0.jar javax.activation-api-1.2.0.jar jcl-over-slf4j-1.6.6.jar pi4j-core-2.1.1.jar slf4j-log4j12-1.6.6.jar amqp-client-5.14.0.jar jaxb-api-2.3.1.jar log4j-1.2.17.jar slf4j-api-2.0.0-alpha5.jar` – srock Jan 08 '22 at 01:37
  • Ask a new question showing what you have done. – greg-449 Jan 08 '22 at 08:11
  • I did it using the jlink command outside of the eclipse IDE. – srock Jan 20 '22 at 01:09

0 Answers0