Saber Mhadhbi
Saber Mhadhbi

Reputation: 23

How to create jar from many java class using netbeans?

I have a java package with many java class and many main. i wish to make jar from these package ? can you help me please ? (i work with netbeans )

Upvotes: 0

Views: 295

Answers (3)

Jad Chahine
Jad Chahine

Reputation: 7149

If the project is under netbeans IDE, you should follow these steps:

  • Right click on the project and then click on Properties

  • Click on Packaging

  • Click on Compress JAR File

  • Accept changes, click OK

  • Right click on the project and then click on Clean and Build

  • Go to the directory where your project is stored

  • Look in the dist folder for the JAR file

    To select the main class that will be executed

  • Click on Run

  • Click on Browse near to Main Class label

    enter image description here

    EDIT :

    If you are using netbeans under windows, and if the jar file does not generate any output, try the following command in cmd :

    start /b <jar file>
    

    Then an error should appear

    So you can know what is the problem

    Upvotes: 3

  • Priyamal
    Priyamal

    Reputation: 2969

    Right click on the the project in net beans project window and choose Project Properties -> run , there you can setup your main class

    clean and build your project and go to your netbeans project -> your project -> dist there is the executable jar file.

    selected main class will be executed when you execute the generated jar file

    Upvotes: 0

    sayal adhikari
    sayal adhikari

    Reputation: 116

    I found this site useful... Hope it helps deploying jar

    Upvotes: 0

    Related Questions