I'm trying to write a shell code that will execute my Java program. I tried this:
#!/bin/sh
COMPILECMD="javac server.jar"
RUNCMD="java -jar server.jar 12777"
$COMPILECMD
$RUNCMD
But I got this error:
error: Class names, 'server.jar', are only accepted if annotation processing is explicitly requested 1 error Failed to load Main-Class manifest attribute from server.jar
In the command line I don't use the jar file, I just compile and then execute:
javac server.java
java server 12777
javaccompiles Java source files into class files - it doesn't create a Jar. To do that, you need to use thejarcommand as well (and configure what the main-class is so it can create the appropriate manifest). However, you might like to consider usingantormavento perform the compilation and jarring up of the class files.serverto be the defaultmain()class of the jar you need to also create a manifest file saying so.