Search code examples
javamainclass

Finding the Main Class


I have my first application written in Netbeans, with supporting libraries. After building the project, the file NetbeansProjects/PDF/dist/PDF.jar runs fine.

I'm ultimately trying to build a OSX app, but think(?) that the first step is to bundle the PDF.jar and the /lib/*.jar files together.

To this end, I'm using JarSplice, but can't work out how set the Main Class. I think it should be found in the manifest.mf file, but it doesn't seem to contain anything. JarSplice requests:

Enter your applications main class file below, complete with any packages that it maybe in. E.g: my package.someotherpackage.MainClass

Adding System.out.println(main.getClassName()); to my main method gives me "PDF" in the output window of Netbeans.

Can someone tell me how I go about finding the main class, and ideally, because I'm an idiot, exactly what to input into as the main class into JarSplice?


Solution

  • It depends were you put your main class when developing. Try the class name that contains your main method, if you put your main method in Test.java then put;Test

    If your main class is nested in a package then put something like org.package.Test

    Once you export your .jar open up the Manifest file and next to Main-Class: should have the main class, just copy and paste