How to run a jar file with the command line

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.