0

I created a project wich plays simple ivr prompt, then compiled it and made a jar file. but I don't know how to run it.
I tried alternative way: placed .class files in usr/services/simpleProject/classes path and mapped it correctly then it works. But I need to run it with .jar file, any sugessions?

LeXuS
  • 19
  • 2
  • 8

2 Answers2

-1

I believe you did't include a MANIFEST file in your jar. Take a look at Documentation.

Alternatively you can run the jar file as mentioned in this question without specifying the main class.

Community
  • 1
  • 1
-1

Perhaps an example would help!

If Unix-based...

mkdir mypkg
cat > mypkg/MyClass.java
package mypkg;
public class MyClass {
  public static void main(String[] args) {
    System.out.println("executing main!");
  }
}

[give Control-D]

javac mypkg/MyClass.java
cat > manifest.txt
Main-Class: mpkg.MyClass

[give Control-D]

jar cfm MyJar.jar manifest.txt mypkg/*.class
java -jar MyJar.jar

Should yield:

executing main!


If Windows-based...

mkdir mypkg
copy con: mypkg\MyClass.java
package mypkg;
public class MyClass {
  public static void main(String[] args) {
    System.out.println("executing main!");
  }
}

[give Control-Z]

javac mypkg\MyClass.java
copy con: manifest.txt
Main-Class: mpkg.MyClass

[give Control-Z]

jar cfm MyJar.jar manifest.txt mypkg\*.class
java -jar MyJar.jar

Should yield:

executing main!

unigeek
  • 2,656
  • 27
  • 27