Assuming you've configured the JRE environment, you now have a packaged jar file that you can start running
Java-classpath Example.jar MainClass
-classpath tells the virtual machine where to find the byte code of the class, by the way, the virtual airborne into the class is lazy loaded, only when practical to load, the virtual machine in accordance with the following order to search and load:
1 bootstrap classes, base class. such as the library class in Java
2 extension classes, extension class. such as the class under the/jre/lib/ext
3 user-defined classes, user-defined classes, like the mainclass above.
Just running the above command sometimes comes with the following error,
Java.lang.SecurityException:no manifest section for signature file entry ...
This is because some files require signature verification, we can manually remove these files to achieve the purpose of execution. Remove SUN_MICR from the Meta-inf directory. RSA and SUN_MICR. SF file is available.
mkdir tmp
CD tmp
JAR-XVF. /hongchangfirst.jar
RM meta-inf/sun_micr.*
Jar CVF. /hongchangfirst.jar *
Cd..
RM-RF tmp
Original: http://blog.csdn.net/hongchangfirst/article/details/25606509
Author: Hongchangfirst
Hongchangfirst's homepage: http://blog.csdn.net/hongchangfirst
How to run a jar file with the command line