How to run a JAR file

前端 未结 11 2150
长发绾君心
长发绾君心 2020-11-22 04:18

I created a JAR file like this:

jar cf Predit.jar *.*

I ran this JAR file by double clicking on it (it didn\'t work). So I ran it from the

11条回答
  •  感情败类
    2020-11-22 04:45

    I have this folder structure:

    D:\JavaProjects\OlivePressApp\com\lynda\olivepress\Main.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\press\OlivePress.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\olives\Kalamata.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\olives\Ligurian.class D:\JavaProjects\OlivePressApp\com\lynda\olivepress\olives\Olive.class

    Main.class is in package com.lynda.olivepress

    There are two other packages:

    com.lynda.olivepress.press

    com.lynda.olivepress.olive

    1) Create a file named "Manifest.txt" with Two Lines, First with Main-Class and a Second Empty Line.

    Main-Class: com.lynda.olivepress.Main
    

    D:\JavaProjects\OlivePressApp\ Manifest.txt

    2) Create JAR with Manifest and Main-Class Entry Point

    D:\JavaProjects\OlivePressApp>jar cfm OlivePressApp.jar Manifest.txt com/lynda/olivepress/Main.class com/lynda/olivepress/*

    3) Run JAR

    java -jar OlivePressApp.jar

    Note: com/lynda/olivepress/* means including the other two packages mentioned above, before point 1)

提交回复
热议问题