plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).
http://plasma-umass.github.io/doppio-demo
MIT License
2.16k stars 174 forks source link

Error running scala code #461

Closed ashishtara closed 8 years ago

ashishtara commented 8 years ago

I'm trying to run a jar (sworld.jar, attached) which I created from scala. I'm able to run it from java with the following command - java -cp scala-library.jar;sworld.jar sworld.HelloWorld

But trying the same thing in Doppio gives the error "Could not find or load main class sworld.HelloWorld". The same error occurs in both the browser as well as the CLI version.

Do I need to have a different mechanism for running jars containing scala code? (A similar hello world sample written in java works fine). Here's the code I tried in the browser version (both scala-library.jar and sworld.jar are placed parallel to the classes and vendor folders) -

new Doppio.VM.JVM({ doppioHomePath: '/sys', javaHomePath: '/sys/vendor/java_home', classpath: ['/sys/classes', '/sys/scala-library.jar', '/sys/sworld.jar'] }, function(err, jvm) { jvm.runClass('sworld.HelloWorld', [''], function(exitCode) { }); });

sworld.zip

jvilk commented 8 years ago

Have you tried with the : path separator in the classpath? Doppio emulates a Unix environment, which uses : instead of ; like in Windows.

ashishtara commented 8 years ago

I see the same error with : as well (using the CLI version with the scala jar). Incidentally, I just saw that using the CLI version the jar containing java code also gives the same error (the same jar that worked fine with the browser). So the problems in the CLI and browser versions might have different causes.

ashishtara commented 8 years ago

A clarification regarding the above comment - by "CLI version" I mean the one using doppio.bat from the command prompt (not the one using Doppio.VM.CLI in the browser)

jvilk commented 8 years ago

@ashishtara Ah, the Node frontend does not work in Windows because it expects a Unix environment. See https://github.com/plasma-umass/doppio/issues/423 . I'm not planning on fixing it any time soon (since DoppioJVM's main use case is the browser), so any help I can get from the community is appreciated.

I just tried your code in the demo, and it worked:

$ java -cp sworld.jar:scala-library-2.10.3.jar sworld.HelloWorld          
Hello, world!

It's likely your setup code for the file system is not correct, so DoppioJVM cannot load the JAR files or something.

ashishtara commented 8 years ago

Found it - I had not regenerated listings.json after adding the new jars (sworld and scala-library) - placed in /sys. Regenerating listings.json fixes the problem. Thanks!