Generating jar file from a project

I am trying to create jar file.
I selected Module settings -> Artifacts and moved all items to jar:
Снимок-10.png
I built artifact and tryed to execute it:

smix@smix-desktop:~/IdeaProjects/untitled/out/artifacts/unnamed$ java -jar unnamed.jar Invalid or corrupt jarfile unnamed.jar



Google said me that I need manifest file. I created it:

Manifest-Version: 1.0 Main-Class: HelloWorld



and added to jar file:
Снимок-11.png

Now i get this error:

smix@smix-desktop:~/IdeaProjects/untitled/out/artifacts/unnamed$ java -jar unnamed.jar Exception in thread "main" java.lang.NoClassDefFoundError: scala/ScalaObject      at java.lang.ClassLoader.defineClass1(Native Method)      at java.lang.ClassLoader.defineClass(ClassLoader.java:634)      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)      at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)      at java.net.URLClassLoader.access$000(URLClassLoader.java:73)      at java.net.URLClassLoader$1.run(URLClassLoader.java:212)      at java.security.AccessController.doPrivileged(Native Method)      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)      at java.lang.ClassLoader.loadClass(ClassLoader.java:321)      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)      at HelloWorld.main(HelloWorld.scala) Caused by: java.lang.ClassNotFoundException: scala.ScalaObject      at java.net.URLClassLoader$1.run(URLClassLoader.java:217)      at java.security.AccessController.doPrivileged(Native Method)      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)      at java.lang.ClassLoader.loadClass(ClassLoader.java:321)      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)      at java.lang.ClassLoader.loadClass(ClassLoader.java:266)      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)      ... 13 more

2 comments
Comment actions Permalink

Resolved.
I have modified manifest:

Manifest-Version: 1.0 Main-Class: HelloWorld Class-Path: scala-library.jar


and put scala-library.jar at the same directory as the jar file(out/artifacts/projectname)
0
Comment actions Permalink

Why does IntelliJ not by default generate a directory with a fully executable file?

I run itnto the same issue with the simplest of simple program (hello world).

0

Please sign in to leave a comment.