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?
run .jar file asterisk-java
644 Views Asked by LeXuS At
2
There are 2 best solutions below
0

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!
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.