This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Distributing a Scala application

3 replies
Gilles SCOUVART
Joined: 2009-03-06,
User offline. Last seen 42 years 45 weeks ago.
Hello all,   I need help creating a distribution for a small Scala app. I have no trouble running it under my Eclipse environment, but when I try to run it from a jar file, I get the common "NoClassDefFoundError" for scala/ScalaObject, even if the scala library is properly added to the classpath. Any idea of what's happening? I guess I'm missing something obvious. BTW, could someone give me a hint (command-line example...) on how to use the Packloader http://scala.sygneca.com/code/compressed-executable-jar ?   Many thanks in advance!

Gilles Scouvart

Mark Harrah
Joined: 2008-12-18,
User offline. Last seen 35 weeks 3 days ago.
Re: Distributing a Scala application

Hi,

I don't know what your command line looks like, but you will get a NoClassDefFoundError if you are doing:

java -cp scala-library.jar -jar app.jar

The -cp option is ignored when -jar is specified, so you need to do something like:

java -cp scala-library.jar:app.jar app.Main

-Mark

On Friday 27 March 2009 13:58, Gilles SCOUVART wrote:
> Hello all,
>
> I need help creating a distribution for a small Scala app. I have no
> trouble running it under my Eclipse environment, but when I try to run
> it from a jar file, I get the common "NoClassDefFoundError" for
> scala/ScalaObject, even if the scala library is properly added to the
> classpath.
> Any idea of what's happening? I guess I'm missing something obvious.
> BTW, could someone give me a hint (command-line example...) on how to
> use the Packloader
> http://scala.sygneca.com/code/compressed-executable-jar ?
>
> Many thanks in advance!
>
> Gilles Scouvart
>
>

Gilles SCOUVART
Joined: 2009-03-06,
User offline. Last seen 42 years 45 weeks ago.
RE: Distributing a Scala application

Thanks Mark,

Finally I got my manifest right. And this small packloader is definitely
a good idea!

Gilles.

-----Original Message-----
From: Mark Harrah [mailto:harrah@bu.edu]
Sent: vendredi 27 mars 2009 20:59
To: scala-user@listes.epfl.ch
Subject: Re: [scala-user] Distributing a Scala application

Hi,

I don't know what your command line looks like, but you will get a
NoClassDefFoundError if you are doing:

java -cp scala-library.jar -jar app.jar

The -cp option is ignored when -jar is specified, so you need to do
something like:

java -cp scala-library.jar:app.jar app.Main

-Mark

On Friday 27 March 2009 13:58, Gilles SCOUVART wrote:
> Hello all,
>
> I need help creating a distribution for a small Scala app. I have no
> trouble running it under my Eclipse environment, but when I try to run

> it from a jar file, I get the common "NoClassDefFoundError" for
> scala/ScalaObject, even if the scala library is properly added to the
> classpath.
> Any idea of what's happening? I guess I'm missing something obvious.
> BTW, could someone give me a hint (command-line example...) on how to
> use the Packloader
> http://scala.sygneca.com/code/compressed-executable-jar ?
>
> Many thanks in advance!
>
> Gilles Scouvart
>
>

Frank Teubler
Joined: 2009-01-22,
User offline. Last seen 3 years 37 weeks ago.
Re: Distributing a Scala application

Mark Harrah wrote:
>
> java -cp scala-library.jar -jar app.jar
>

I start my scala applications with scala itself.

Instead of
java -cp scala-library.jar:app.jar app.Main

I call
scala -cp app.jar app.Main

So the scala libraries are attracted automatically.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland