• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JAR execution problems

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic