Reputation:
File PrintTest.java
:
public class PrintTest{
public static void main(String[] args){
System.out.println("Why are you executing me?");
}
}
File Manifest.txt
Main-Class: PrintTest
My command I ran to compress to .jar
:
jar cfm PrintTest.jar Manifest.txt PrintTest.class
I also tried this (even though it doesn't matter):
jar cmf PrintTest.jar Manifest.txt PrintTest.class
My Directory Structure:
C:\Program Files\Java\jdk1.6.0_24\PrintTest_jar
PrintTest_jar
: PrintTest.java
, PrintTest.class
, Manifest.txt
, PrintTest.jar
When I double-click on the .jar
file, nothing happens. No errors, nothing.
PrintTest.class
runs fine from the command line. I'm also running on Windows.
Upvotes: 0
Views: 2711
Reputation: 11
My dear friend, your application is a DOS program and would only run in DOS, your did not create a GUI program, if it was a GUI program, it would at least display on the Computer.....DOS is meant for DOS..... sorry.
Upvotes: 1
Reputation: 11
The code that was given to you to delay it is correct. However, you need to import an utility from Java libraries for it to work. Type in this before even your class body.
import java.util.Scanner
Upvotes: 1
Reputation: 9793
If I understand your question and the display of your manifest text file then you must ensure that the text file contains a new-line after the last line of text or it will not be processed properly. Please see this for more info: http://download.oracle.com/javase/tutorial/deployment/jar/modman.html
Upvotes: 2
Reputation: 66713
When I double-click on the .jar file, nothing happens. No errors, nothing!
When launched like that, the console window will immediately disappear when the program has finished executing. To see the output, you should run the program from the console instead of double clicking the jar file.
edit: To delay the program termination, you could do this:
Scanner scanner = new Scanner(System.in);
System.out.print("Press Enter to exit...");
scanner.next();
However, I think it makes more sense to just run console applications from the console.
Upvotes: 2