简体   繁体   中英

Unable to run jar file

MANIFEST.MF

Manifest-Version: 1.0  
Created-By: 1.7.0_01 (Oracle Corporation)  
Main-Class: useDisplay

NOTE: There is a blank line after the Main-Class

display.java

public class display  
{  
    public void displayText()
    {
       System.out.println ("In displayText");
    }
}

useDisplay.java

public class useDisplay  
{
   public static void main (String args[])  
   {
      System.out.println ("In displayText");
   }
}

I ran the following commands:

javac *java
jar cf my1.jar MANIFEST.MF *class  
java -jar my1.jar  

I got the following errors:

Exception in thread "main" java.lang.NullPointerException at 
sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:399) 

at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:463)

This should be a very simple example. The program works without the jar file. I have no idea what it's complaining about.

我相信您必须在jar命令中添加-m才能使用您指定的MANIFEST.MF文件

jar cfm my1.jar MANIFEST.MF *class

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