Run the. jar file with a. bat file or cmd.

Source: Internet
Author: User

Use the. bat file or cmd to run the. jar file as follows:

1. Run the jar file in the. bat file

Java-jar +jar file path to a text file, and then modify the suffix name to Xxx.bat and then double-click to open the following example:

Java-jar D:\test\me_active.jar

2. Run directly in the CMD window

In the cmd inside direct run Java-jar D:\test\me_active.jar This sentence on the line

Note: The JDK installation is correct and the jar file can be executed.

3. You can specify initialization parameters for the main method execution, such as your executable file as follows:

Import Java.awt.Frame;
public class Testframe {
public static void Main (String args[]) {
String s = args[0];
Frame f = new frame (s);
F.setsize (200,100);
F.setvisible (TRUE);
}
}

The file after the export is Test.jar you can write this when you run:

Java-jar D:\test.jar 123 456

Then the results after the run are:

To export a method that performs a. jar file:

Select an item, right-click the export, select Java-> to run the jar file, select the Java file that the main method runs, select the exported file location and file name, and then click Finish to generate the executable. jar file, and then you can run it where you need it.

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.