0

I'm trying to run my java class with dependencies in the command line. And I'm used IntelliJ Idea 13 to build artifact from my project. I have a main class say "Main.java" and after the build I got a jar file like mytest.jar. The Main.java's full qualified name is like "test.Main"

But when I'm trying to run it using "java mytest.jar", it complained that cannot find main class mytest.jar.

I checked the files in the jar and it seems like I got all the dependencies I need, and the main class in the MANIFEST.MF seems also ok. And actually if I unzip the jar into "mytest" folder, and try run "java test.Main" in it I works good.

My jar file is like this:

mytest

--test

----Main.class

--META-INF

----MANIFEST.NF

--org... //dependencies

My MANIFEST.MF is like this:

Manifest-Version: 1.0

Main-Class: test.Main

So what's your advice?

UPDATE: the Main-Class MANIFEST.MF is test.Main, I'm using a simple example in this question and forgot to change the content, sorry.

Community
  • 1
  • 1
MagicFingr
  • 479
  • 6
  • 20
  • 1
    How do you execute it in the command-line? Check answers to a similar question here http://stackoverflow.com/questions/5774970/run-jar-file-in-command-prompt – Omoro Apr 28 '14 at 14:40
  • 3
    If your main class's fully qualified name is `test.Main`, why have you specified `example.SimpleServer` in your manifest? Just fix your manifest... – Jon Skeet Apr 28 '14 at 14:41

1 Answers1

1

In your manifest, the Main-Class attribute should be test.Main. I haven't used Idea yet, but for example in Eclipse, you can specify a Run configuration the executable jar file will be generated with.

Sleeper9
  • 1,707
  • 1
  • 19
  • 26