Search code examples
javajarsolarisrad

Failed to load Main-Class manifest attribute from myFile.jar error


I'm using IBM's Relational Application Developer (RAD) as my IDE. I have one Java class in my project and I named it extract.java. I have couple of library files and resources files associated with my project. I exported my project as a jar file using IDE and ran it through command line on solaris environment using following query:

$java -jar myFile.jar 

I get the following error:

Failed to load Main-Class manifest attribute from myFile.jar

I saw suggestions that manifest file needs to be updated. I'm not sure what does that mean since I'm new to java and any help will be great.

PS: There are no errors when I run class as Java Application from IDE on windows machine.

enter image description here


Solution

  • In order to make a JAR an Executable JAR within RAD, do the following steps:

    1. Right click on the project and select Export...
    2. Select Java > Runnable JAR file and click Next.
    3. In the Launch Configuration field, select your Java class that contains the public static void main(String[] args) method.
    4. Specify the destination location.
    5. Lastly, define how the libraries, if any, in your project should be packaged in the JAR.
    6. Click Finish.

    This should create the Manifest file with the correct Main-class header. Run the JAR with the java -jar command to make sure it's working.

    Hope this helps.