Eclipse: how to generate jar files and scaladoc

500 views
Skip to first unread message

Klaus Havelund

unread,
Feb 8, 2013, 7:22:10 PM2/8/13
to scala...@googlegroups.com


There are two things that I find complicated using the Scala Eclipse IDE:

  1) generating jar files.
  2) generating scaladoc from your commented Scala program

Concerning issue (1), the technique suggested is described here:

    http://stackoverflow.com/questions/6773180/generate-jar-from-scala

However, this seems slightly complicated, and more importantly, I am not sure how to generate a jar with all
dependencies, including the Scala system (as I don't want the user of a jar to be forced to install Scala).

Are there any good solutions to these problems? Those issues seem like basic issues to be solved, and
as far as I know are reasons for some to use SBT rather than Eclipse.

Klaus

pagoda_5b

unread,
Feb 9, 2013, 3:12:17 AM2/9/13
to scala...@googlegroups.com
This is a common issue that comes from the java world, packaging and installing is not done in the same way as for compiled code in other languages.
This is a consequence of the fact that JVM code is made to be portable on any platform, through the use of the Virtual Machine that resides on the host machine.
In this scenario, the host system is supposed to have the Java Runtime Environment (the native environment for the JVM on the specific platform) installed, while the application code can be portable and once compiled in "bytecode" it will run on any compatible (as of version) JRE.
That's the soul of the java slogan "write once, run everywhere".

Now that we've gone over the history lesson, there are solutions, more or less official, to embed the runtime with your application, proposed for the java ecosystem. This is equivalent for scala, since the scala code is compiled exactly as java is, so the final artifact can run on the JRE. You only need to take care that the scala-lang jar is included with your dependencies.

As for packaging the jars fot project dependencies, here we have other options, but I don't know of any that's directly offered by Eclipse.
For sbt there's a plugin called OneJar, available here: https://github.com/sbt/sbt-onejar
It packages in a single jar all the dependencies declared in the sbt build file.

I suppose you can find similar solutions for Maven.

I can't say about eclipse, but for certain, you can export a project in a jar using the File>export menu.

bye
Ivano

Klaus Havelund

unread,
Feb 9, 2013, 1:37:45 PM2/9/13
to pagoda_5b, scala...@googlegroups.com
Thanks for the history of Java, which I am very well aware of, not
sure what it has to do
with my question though.

> I can't say about eclipse, but for certain, you can export a project in a
> jar using the File>export menu.

But that was my question. And no, you can't export a jar file just like that.

klaus
> --
> You received this message because you are subscribed to the Google Groups
> "scala-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scala-user+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Simon Schäfer

unread,
Feb 10, 2013, 2:34:46 PM2/10/13
to scala...@googlegroups.com, pagoda_5b
Hi Klaus,

both of your points can not be solved with Scala IDE at the moment. There are tickets available:

1) https://scala-ide-portfolio.assembla.com/spaces/scala-ide/tickets/1000022-enable--runnable-jar-file--wizard-to-recognize-scala-application#/activity/ticket:

2) https://scala-ide-portfolio.assembla.com/spaces/scala-ide/tickets/1001504-scaladoc-generation#/activity/ticket:

If you want to deploy your software, you need to use a build tool. Currently we can only wait until the tickets for the Scala IDE are solved (or solve them by ourself...).

Klaus Havelund

unread,
Feb 11, 2013, 1:49:46 PM2/11/13
to scala...@googlegroups.com, pagoda_5b

Ok, thanks!

Klaus
Reply all
Reply to author
Forward
0 new messages