6

I know you may blame me for this being a dupe - but frankly, I do not know what to do next. I spent hours online trying to find my solution, and have found nothing. Zilch. Zero.

Anyway, this is my problem: when I double click my runnable jar file, it shows a hourglass cursor for a second and then it disapears, leaving me with nothing. I have re installed my JDK and JRE 2 times, and nothing happens. Here is my manifest file:

Manifest-Version: 1.0
Class-Path: .
Main-Class: gedr.proj.Paint.Frame

I have tried to run my application via the command line, but am baffled by how to do it.

Tell me if you need any more information, or tell me what to do. Thanks in advance

EDIT: If I try 'java -jar PaintV2.jar' in cmd, it returns

Error: Unable to access jarfile PaintV2.jar

when I run 'ftype | find "jarfile"' it returns

jarfile="C:\Program Files\Java\jre7\bin\javaw.exe" -jar "%1" %*
gedr
  • 316
  • 1
  • 2
  • 12
  • 4
    Navigate to the directory in which your JAR is placed (using `cd`) and then do: `java -jar "jar file name.jar"` – Josh M Jan 31 '14 at 22:56
  • It returned a error message! Thank you! – gedr Jan 31 '14 at 22:59
  • @JoshM When I run it in the command line, I get a error saying that ImageIO cannot be read, but when I run it in eclipse it does not say anything. Here is the line of code: originalImage = ImageIO.read(new File("resources\\colorwheel.png")); Does it have something to do with the filepath? If so, how can I get the file path towards the resource file in my project? Thanks – gedr Jan 31 '14 at 23:08
  • 1
    @gedr Usually jar files don't like `new File(...)`. Use `Class.getResourceAsStream(...)`, instead. – afsantos Jan 31 '14 at 23:15
  • @afsantos I am using this code ' originalImage = ImageIO.read(Frame.class.getResourceAsStream("/resources/colorwheel.png"));' but it gives me an error that input == null (IllegalArgumentException). Do you have any idea on how I could load a image from my jar file? – gedr Jan 31 '14 at 23:53
  • 1
    @gedr The documentation states that `null` is returned if the resource can't be found. Check that the path is correct. Maybe [this answer](http://stackoverflow.com/a/19388209/2088822) is of help. If the problems persist, consider posting another question with your new issues, since this question is about running a jar with a double click. – afsantos Feb 01 '14 at 00:10
  • @afsantos Thanks, I got all the problems sorted! Thank you all for helping! – gedr Feb 01 '14 at 15:43
  • @gedr - it is customary to mark the earliest answer that answered your question as "the answer"; it provides points to the person who answered it, and incidentally helps identify you as a person who marks answers to his/her questions. Also upvote any answers that are helpful, including the main one; this also provides reputation points and indicates to other readers which answers to look at if they have the same problem(s). – arcy Jul 15 '14 at 16:39

2 Answers2

5

Navigate to your file in cmd, and then type

java -jar jarfile.jar

If you can could you upload the file please?

Roberto Anić Banić
  • 1,411
  • 10
  • 21
1

In the command line type java -jar jar_name.jar.

If there are any errors it will show you.