Reputation: 427
I have a directory structure like this:
TestJlink
-src
--module-info.java
--com
---company
----TestJLink
-----TestJLink.java
I run this jlink --module-path src --add-modules com.company.TestJLink --output outputJRE
I get Error: Module com.company.TestJlink not found
The contents of my module-info.java is this:
module com.company.TestJlink {
requires java.desktop;
requires com.microsoft.sqlserver.jdbc;
requires java.sql;
requires sshj;
}
My TestJLink.java contains this
package com.company.TestJLink;
imports ...
public class TestJLink {
TestJlink(){}
...
}
I am using java 11
I am able to build it using this: java -p C:\Users\Administrator...\target\classes;C:\Users\Administrator.m2\repository\com\microsoft\sqlserver\mssql-jdbc\8.4.1.jre11\mssql-jdbc-8.4.1.jre11.jar;C:\Users\Administrator.m2\repository\com\hierynomus\sshj\0.27.0\sshj-0.27.0.jar;C:\Users\Administrator.m2\repository\org\bouncycastle\bcprov-jdk15on\1.60\bcprov-jdk15on-1.60.jar;C:\Users\Administrator.m2\repository\org\bouncycastle\bcpkix-jdk15on\1.60\bcpkix-jdk15on-1.60.jar;C:\Users\Administrator.m2\repository\com\jcraft\jzlib\1.1.3\jzlib-1.1.3.jar;C:\Users\Administrator.m2\repository\net\i2p\crypto\eddsa\0.2.0\eddsa-0.2.0.jar;C:\Users\Administrator.m2\repository\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;C:\Users\Administrator.m2\repository\org\slf4j\slf4j-log4j12\1.7.5\slf4j-log4j12-1.7.5.jar;C:\Users\Administrator.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar -m com.company.TestJLink/com.company.TestJLink.TestJLink
Upvotes: 0
Views: 1768
Reputation: 427
solved it by first doing javac which I was also having problems with. The solution I found was just to add this to the end of the javac src\module-info.java src\com\company\TestJLink\TestJLink.java
After it was compiled, I was able to jlink it. The problem I had earlier with jlinking it was I was referencing the src, not the compiled .class files.
jlink --module-path --output testjre --add-modules com.company.TestJLink -p ... any other dependencies from maven jars etc.
Now I am getting this error, Error: automatic module cannot be used with jlink. This should be fun, but it has to do with my maven dependencies and not the actual example.
Upvotes: 0