I used eclipse to create executable jar. It relies external other jars.
In Eclipse, It is simple that you just need to choose Extract required libraries into generated JAR
.
You can create an executable jar. It can be executed any places where jre is installed.
But If I use command line to compile jar.
javac -classpath [external jars] *.java
jar cfm [a name].jar manifest *.class [external jars]
It can generate jar. But the jar can only be executed in the directory where it is produced.
If I put it into another directory or machine, it complains NoClassDefFoundError
.
So, my question is that how I can generate executable jar using command line as Eclipse.