2

Ive been trying to create a jar file for quite a bit of time now... Ill show my code

Main Java File:

Main.java

MANIFEST.txt:

Main-Class: Main

Jar Creation Command:

jar cmf MANIFEST.txt GUI.jar *.class

I compile and run the java files and I do not notice any issues until after I create the Jar file... After I create the Jar file, when I try and launch it (from the command line) it gives me the following error:

Error: Could not find or load main class

I took the jar file after trying to re-create the Jar several times with slightly different commands, and extracted the contents of the car. Afterwards I discovered that this is what actually loaded into the manifest.txt file:

Manifest-Version: 1.0
Created-By: 1.8.0_45 (Oracle Corporation)

Im not sure how, or why it happened.

I changed the Manifest.txt file to what the file originally was before the creation of the Jar file and recompressed the file into a jar and tried to run it again, but still nothing...

Community
  • 1
  • 1
pmiccich
  • 49
  • 1
  • 2
  • 9
  • Please do clarify, are you actually pressing __ENTER__ key inside `manifest.txt` after writing `Main-Class: Main`? If you could paste `Main.java`, we'll try to create a `.jar` file for you :-), if that is not too much to ask for. Here for trying, a small [example](http://stackoverflow.com/a/15187181/1057230) and [another](http://stackoverflow.com/a/9613766/1057230), hopefully it might can help – nIcE cOw Jul 25 '15 at 02:49
  • 1
    I can do that In just a moment... I got a bit fed up and am mostly done remaking the whole thing in NetBeans... I know its not a good idea to give up that quickly when you are learning but I just needed this to work haha. – pmiccich Jul 25 '15 at 04:00
  • The issue I had seemed to have been fixed after I reinstalled my JDK... What could the reasons be behind that fixing it? – pmiccich Jul 25 '15 at 13:32

1 Answers1

-1

Obviously you are running

java jar ...

instead of

java -jar ...
user207421
  • 305,947
  • 44
  • 307
  • 483
  • That is actually what I was doing, I typed my example incorrectly. Sorry about that! – pmiccich Jul 25 '15 at 03:59
  • No. You left out the `-`. You were trying to run a main class called `jar`, as per the first example. The error message proves it. – user207421 Jul 25 '15 at 07:26