0

I've created a jar file like this:

jar cfmv Manifest.mf RoboPlot.jar RoboPlot.class ImagePlotter.class

The manifest.mf file looks like this:


Main-Class:RoboPlot

For some reason, when I use this command to run it,
java -jar RoboPlot.jar

it tells me that the main class could not be found

I also tried this:

Manifest-Version: 1.0
Created-By: 1.5.0 (Sun Microsystems Inc.)
Main-Class:RoboPlot

and it didn't work either.

6
Contributors
12
Replies
14
Views
12 Years
Discussion Span
Last Post by stultuske
0

Maybe another stupid idea: check that your RoboPlot class has a method with the exact signature required for a main method (i.e. public static void main(String[] args) ).

0

I read something that said the main class cannot contain any package statements....Is this true? If it is, that's my problem, because I import swing, awt, and all that good stuff.

0

untrue.
Java is all about packages.
Maybe the reason it cannot find the class is that you didn't put it in a package?
Default package (a.k.a. no package) is dangerous and should be avoided.

0

Should I put all of my classes in a package? I mean, is that what they meant, because I took it as I needed to create a whole new class, that only created an instance of the main one.

0

You should always use packages. It's not officially mandated by the JLS but in practice it's the only way to go.
For example you can not import a class that is not in a package from any class that is in a package. You can also not create instances of it (though there are ways to do so using reflection, but that's rather convoluted).

0

Yeah I tried that..I'm getting an invalid header error, and I've tried all sorts of combinations to see if I could get it to work..But, I did add the blank line at the end.

0

Hi everyone,


I noticed that you did no have a space at the :

Main-Class:RoboPlot

I think it should be

Main-Class: RoboPlot

Try this

(start at beginning of file)
Manifest-Version: 1.0
Main-Class: RoboPlot
(blankline)

Let me know if it works

Richard West

0

Thank you for replying, unfortunately this didn't work(Don't know why). I added the space between the :, and a blank line at the end. It still gave me an invalid header field when ran. You have anymore suggestions or thoughts about this?

0

fatih54102:
after more than 6 years, I'm pretty sure that, even if the OP hasn't finished yet, he doesn't really care anymore.

don't revive dead threads, it's useless and a waste of time.

could one of the admins please close this thread?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.