Hi,
I'm currently trying to create a .jar file to run a program (minecraft server) that is basically started by a .bat script that contains:
java @parameter_hoder_text.txt %*
and in the .txt file:
then the case is, that if I run the .bat file by clicking on it, it runs without any problem but if I try to run it from a .jar file, it fails to load the modules.-p "a lot of path" --add-modules ALL-MODULE-PATH --add-opens java.base/java.util.jar=cpw.mods.securejarhandler --add-opens java.base/java.lang.invoke=cpw.mods.securejarhandler --add-exports java.base/sun.security.util=cpw.mods.securejarhandler . . .
WARNING: Unknown module: cpw.mods.securejarhandler specified to --add-exports
WARNING: Unknown module: cpw.mods.securejarhandler specified to --add-opens
WARNING: Unknown module: cpw.mods.securejarhandler specified to --add-opens
Error: Could not find or load main class cpw.mods.bootstraplauncher.BootstrapLauncher
Caused by: java.lang.ClassNotFoundException: cpw.mods.bootstraplauncher.BootstrapLauncher
Press any key to continue . . .
I even tried executing the code in the .bat file in my .jar
andProcessBuilder pb = new ProcessBuilder("cmd", "/c", "start", ".../...run.bat");
but this way It still couldn't find the modules.ProcessBuilder pb = new ProcessBuilder("java","here", "goes", "every", "line", "of", "the", ".txt file");
The reason why I want to run the .bat file from a .jar file is that the program is on a remote server and It only allows me to run .jar files.
Is there any right/import differences when using JVM?
(I just started to learn java today, with a few years of programming experience)
EDIT:
I just succeeded to run the program locally, using:
but on the remote side I have no access to cmd (what a surprise :D )Process p = Runtime.getRuntime().exec("cmd /c start run.bat", null, null);
which leaves me with the only solution:
using the Java code with the parameters in the .txt file.
So the question remains narrowed:
Why does java not find the modules when run from a .jar file?