How to open/run .jar file (double-click not working)?

前端 未结 15 1135
陌清茗
陌清茗 2020-12-15 17:26

I can\'t open or run my .jar file.

I just installed java, but I tried to open the .jar with other programs first, so the double-click defaults to something else and

15条回答
  •  攒了一身酷
    2020-12-15 17:49

    In cmd you can use the following:

    c:\your directory\your folder\build>java -jar yourFile.jar 
    

    However, you need to create you .jar file on your project if you use Netbeans. How just go to Run ->Clean and Build Project(your project name)

    Also make sure you project properties Build->Packing has a yourFile.jar and check Build JAR after Compiling check Copy Depentent Libraries

    Warning: Make sure your Environmental variables for Java are properly set.

    Old way to compile and run a Java File from the command prompt (cmd)

    Compiling: c:\>javac Myclass.java
    Running: c:\>java com.myPackage.Myclass
    

    I hope this info help.

提交回复
热议问题