Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAR execution problems

 
Bryan Lemmer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am having a problem executing my main java class from a executable jar.

I use the standard "hello world" app to test the program. i complile the program and run it through the command prompt and it all worked fine.

I then use the following statement "jar cvfm test.jar manifest.txt *.class"
which creates the jar file but when i double click on the file nothing happens???

am i doing something wrong or is there a setting somewhere that i need to set.

HELP!!

Cheers
Bryan
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a Main-Class header in your manifest file ?
 
Bryan Lemmer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the code for the class and the mainifest entry:

public class mainTest
{
public static void main(String args[])
{
System.out.println("this is the correct way to run a java app");
}
}

manifest.txt

Main-Class: mainTest
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you type this on the command line to run the application:

java -jar test.jar

Do you get any error messages or does the program run as you'd expect?

Note: Your test program prints out a line of text to the console window. If you start an executable JAR file by double-clicking it, the console window is not opened, and you won't see the output of your program. So, you don't see anything happen.
 
Bryan Lemmer
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper,

I am an IDIOT!! when executing it from the comand prompt it prints the line. Another question while we are on the subject... why doesnt it print a line to the command prompt if i have it open and then double click on the jar file?

Bryan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic