Reputation: 1287
After compiling a java program with javac
$ javac -classpath javax.mail.jar:javax.activation.jar:. PriceEmailer.java
I am including the resultant class and the libraries I used into a jar, however, the jar file will not execute.
Running the java file on the command line works:
$ java -classpath javax.activation.jar:javax.mail.jar:. PriceEmailer
Sending...
Email sent!
Now I want to make an executable .jar
file. I placed the following in manifest.txt:
Manifest-Version: 1.0
Main-Class: PriceEmailer
Class-Path: javax.activation.jar:javax.mail.jar:.
Creating the .jar
file:
$ jar vcfm PriceEmailer.jar manifest.txt class/*
added manifest
adding: class/javax.activation.jar(in = 56290) (out= 50561)(deflated 10%)
adding: class/javax.mail.jar(in = 653275) (out= 617552)(deflated 5%)
adding: class/PriceEmailer.class(in = 4106) (out= 2205)(deflated 46%)
Running the .jar
file:
$ java -jar PriceEmailer.jar
Error: Could not find or load main class PriceEmailer
Why can't the jar file execute?
Note: The main
function is in the file PriceEmailer.java
which defines the PriceEmailer
class.
public static void main(String[] args) throws Exception {
Upvotes: 1
Views: 261
Reputation: 311050
The Class-path entries should be separated by spaces, not colons. See the specification.
Upvotes: 2