scala classpath

120 views
Skip to first unread message

kainaw

unread,
Jun 12, 2012, 10:39:29 AM6/12/12
to scala-user
I'm trying to find a place to get information about classpath and
scala. See the following and please let me know where I can find the
appropriate documentation:

>echo $CLASSPATH

>export CLASSPATH=/usr/share/java/mysql-connector-java.jar:.
>echo $CLASSPATH
/usr/share/java/mysql-connector-java.jar:.
>scala mysql_test.scala
/home/scala/mysql_test.scala:3: error: object mysql is not a member
of package com
classOf[com.mysql.jdbc.Driver]
^
one error found
>scala -cp /usr/share/java/mysql-connector-java.jar mysql_test.scala
Mysql Connection Made

It appears that Scala is unable to use the classpath environment
variable. So, I must type out the entire classpath on the command line
every time I run a Scala program.

Paul Keeble

unread,
Jun 12, 2012, 11:24:30 AM6/12/12
to kainaw, scala-user
Global classpaths are a really bad idea. In your example you could
just use scala -cp $CLASSPATH to use the defined exported variable. If
you really wanted to avoid typing that/you aren't using an IDE then
you could write a simple wrapper script myscala with contents looking
something like this (Unix, can do a similar thing on Windows):

scala -cp $CLASSPATH $*

Which gives the behaviour in a simple form.

PK
Reply all
Reply to author
Forward
0 new messages