简体   繁体   中英

How to create a executable jar with a particular class in a project in netbeans

This is my first question on stack overflow. Please have a look at this first, please!!

I am creating an executable jar file by clicking on the button surrounded with grey color. The problem is that the exxcution of the application always starts from the "PersonalAssistant.java". I want my application to begin its execution from "App.java" which also contains a main() method.

So, basically the jar file which I want should begin its execution from App.java class which has a main method.

I don't know how to change the path or execution class for jar. Please help me!!!! I'm stuck with this silly problem. But I want a solution for this.

I'm using Windows10 with Netbeans 8.2 IDE

You should be able to reconfigure your IDE and rebuild the executable jar specifying which class you want to use as the executable.

in your IDE add java -cp myjar.jar App to your compile command

this might also help

在此处输入图片说明

Look at the picture above. Right-click on your project and select Properties . Select Run . Look for the Application Class field. In my example, I have javafxapplication211.Main . This structure is projectName.MainClass . You should just need to change the MainClass part to the class you want to start your project. For example, if Main.java was starting my app and I wanted to change it to App.java . I would change javafxapplication211.Main to javafxapplication211.App .

If you hit Browse , it will give you a list of available classes that can start the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM