0

With IntelliJ IDEA;

How would I make it so that the JAR can run anywhere without needing the META INF? (Or the Meta INF being inside the JAR??).

At the moment, I plop the JAR on my VPS and it doesn't have the METAINF.

Thank you,

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
Spooker
  • 17
  • 5
  • Why do you need to have a JAR run without a manifest? The only way for the JVM to know what main class to invoke is to use the mainfest. – Alvin L-B Mar 11 '17 at 19:35
  • Tried doing that research thing? I have no idea what you are asking for. Of course you can create jar files without manifest information. But that doesn't really change much, expect for the fact that you can't do "java -jar jarfile" any more. – GhostCat Mar 11 '17 at 19:35
  • @GhostCat I have. Alvin, I don't know how to compile it with the manifest. – Spooker Mar 11 '17 at 19:36
  • Oh, maybe you should rephrase your question, the "without needing the META INF" bit had me confused. Anyway, are you just using the regular artifact system built into IntelliJ to compile? – Alvin L-B Mar 11 '17 at 19:40
  • @AlvinL-B yes. I am just about to try adding the meta inf compile output into the jar. – Spooker Mar 11 '17 at 19:45
  • Already [explained here](https://blog.jetbrains.com/idea/2010/08/quickly-create-jar-artifact/), also a [duplicate of this question](http://stackoverflow.com/a/4901370/104891). – CrazyCoder Mar 12 '17 at 01:34

1 Answers1

1

When creating the artifact in IntelliJ, simply select your Main Class, and the manifest should be automatically generated.enter image description here

Alvin L-B
  • 488
  • 2
  • 8
  • 1
    Next question will be: "Why isn't my executable JAR finding all my dependencies?" Hint: Use Maven to manage them and a plugin to put them inside the JAR. – duffymo Mar 11 '17 at 20:07
  • @duffymo Manual dependency management through IntelliJ isn't as bad as you might think. The dependency management is quite clean and easy to understand for a beginner, and in my opinion, shading is even easier through IntelliJ. Although you are right, with IntelliJ's really nice maven integration, there really isn't much reason not to use it. – Alvin L-B Mar 11 '17 at 20:13
  • Don't get me wrong - I love IntelliJ. I've been using it for 12 years and counting. I agree with your recommendation. My fear is for the situation when that JAR is packaged, deployed, and run outside IntelliJ. Thankfully IntelliJ's Maven support is superb, just as you say. – duffymo Mar 11 '17 at 20:15