How to export a project to a JAR in Scala IDE for eclipse Correctly?

1,776 views
Skip to first unread message

罗辉

unread,
Jul 28, 2016, 2:59:55 AM7/28/16
to Scala IDE User
Hi there:    
I export a project into jar like this "right click my project->choose export ->java-> jar file-> next->choose "src/main/resouces" and ''src/main/scala"'-> clikc browse and choose a jar file export location-> choose overwrite it",  and this jar is unable to run with "java -jar myjar.jar".  It says "no main manifest attribute, in /xxxx/MyJar.jar". It seems the file MANIFEST.MF lost the main class info when I export the jar.
I opened the MANIFEST.MF in my exported jar, and finds only below info:
Manifest-Version: 1.0


However I checked the MANIFEST.MF in my project, it is like this:
Manifest-Version: 1.0
Main-Class: org.abc.spark.streaming.Producer
Class-Path: lib/spark-core_2.10-1.6.1.jar ...........




I also tried to export my project as a runnable jar, but my class can not be run as a java application, the run button is not able to click.
So could anyone share a hand?
 

Thanks&Best regards!
San.Luo

Simon Schäfer

unread,
Jul 28, 2016, 6:02:48 AM7/28/16
to scala-ide-user
Exporting a Scala application as a runnable JAR is not supported. Use a build tool like sbt or maven instead to produce a runnable JAR.


---- On Thu, 28 Jul 2016 08:46:18 +0200 罗辉 <luohu...@gmail.com>wrote ----

--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

hol...@informatik.htw-dresden.de

unread,
Jul 28, 2016, 9:02:07 AM7/28/16
to Scala IDE User
You need to add  the Scala library to you project and provide a Scala wrapper for your project:

public class ScalaRunner {
    public static void main(String[] args) {
        Foo.main(args);
    }
}

Reply all
Reply to author
Forward
0 new messages