1

I have installed Scala via apt but when I try to run the Scala shell, it throws me a NoClassDefFoundError. When I try to run it using superuser privileges,it runs fine. Scalac runs fine without superuser privileges. after running the env command, I saw that SCALA_HOME was there but PATH for scala was not listed. I tried adding the path through bashrc, profile and /etc/environment but it isn't getting added to the PATH. My SCALA_HOME is /usr/share/scala My question is: How do I execute the Scala shell without superusr privileges?

EDIT1: After tweaking with SCALA_HOME and PATH I no longer have SCALA_HOME in my environment

Shankha057
  • 1,296
  • 1
  • 20
  • 38

1 Answers1

1

On my ubuntu system (actually lubuntu) I have the following.

The primary executable in /usr/bin should already be in your $PATH. This is a sym-link to the actual executable.

0 lrwxrwxrwx 1 root root 26 Apr 13 01:24 /usr/bin/scala -> /usr/share/scala/bin/scala

The real scala executable is a bash script.

8 -rwxr-xr-x 1 root root 6208 Apr 13 01:24 /usr/share/scala/bin/scala

Note the file permissions on each.

I don't have SCALA_HOME set in my environment because the scala bash script does it's own calculations to figure that out.

jwvh
  • 50,871
  • 7
  • 38
  • 64
  • I'm using mint. And my objective is to run the scala shell with just "scala" command from the terminal. How do I achieve it? – Shankha057 Aug 29 '17 at 07:35
  • I've shown you how I achieve it. If your setup (links, files, permissions) looks like mine then the problem is elsewhere. If that's the case then it's likely that we don't have enough information to help you solve it. – jwvh Aug 29 '17 at 07:51
  • `lrwxrwxrwx 1 root root 23 Aug 26 20:58 scala -> /etc/alternatives/scala` This is the one in /usr/bin `lrwxrwxrwx 1 root root 31 Aug 26 20:58 scala -> /usr/share/scala-2.11/bin/scala` This is the one in /etc/alternatives `-rwxr-xr-x 1 root root 5783 Dec 22 2015 scala` This is the original exe – Shankha057 Aug 29 '17 at 08:14
  • Execute this command from your home directory: `/etc/alternatives/scala` If you get the REPL then the problem _might_ be one of the sym links. If it fails then the error message is the first clue to tracking down the problem. – jwvh Aug 29 '17 at 08:26
  • NoClassDefFoundError But no problem with sudo Back to square one – Shankha057 Aug 29 '17 at 08:36
  • I also changed the sym-links for the usr/bin/scala to usr/share/scala/bin/scala (which was previously ../share/scala-2.11/..) but still same result *NoClassDefFoundError* – Shankha057 Aug 29 '17 at 09:22
  • The sym-links have already been ruled out. Something in the bash script works in the root environment but not in yours. I suspect that either the `$SCALA_HOME` calculations and/or the `$TOOL_CLASSPATH` calculations are coming up with different results for the different environments, but there's no way to know until the script has been fully traced. – jwvh Aug 29 '17 at 09:40
  • By fully tracing the script you mean?? – Shankha057 Aug 29 '17 at 09:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/153112/discussion-between-jwvh-and-shankhadeep-ghoshal). – jwvh Aug 29 '17 at 09:49