decafjs / decaf

decaf core
MIT License
31 stars 7 forks source link

classpath #2

Open tangdah opened 9 years ago

tangdah commented 9 years ago

Whenever I tried to call decaf from the top of my home directory, the classpath is defined wrong and I get this error message:

$ decaf java -server -Xmx444m -Dfile.encoding=UTF-8 -Djava.awt.headless=true -cp .:/home/tangdah//java/:./java/* -Ddecaf=/home/tangdah org.mozilla.javascript.tools.shell.Main -debug -version 180 -O 9 /home/tangdah/builtins/all.js Error: Could not find or load main class org.mozilla.javascript.tools.shell.Main

The classpath is defined correctly if I call decaf from any other directory:

$ decaf

java -server -Xmx448m -Dfile.encoding=UTF-8 -Djava.awt.headless=true -cp .:/usr/local/decaf/java/* -Ddecaf=/usr/local/decaf org.mozilla.javascript.tools.shell.Main -debug -version 180 -O 9 /usr/local/decaf/builtins/all.js decaf>

tangdah commented 9 years ago

The issue was due to multiple java directories. The classpath of decaf needs to be checked for this possibility. I don't know how to fix this, but here is a partial fix:

if [ -d "java" ]; then

Check if java directory is inside of decaf

if [ -e "bower.json" ]; then
    DECAF=$PWD
    MODULES=$PWD
else
    if [ -d "decaf" ]; then
        DECAF=$PWD/decaf
        MODULES=$PWD/decaf
    fi
fi

fi ... if [ -d "java" ]; then

Check if the java directory is inside of decaf

if [ -e "bower.json" ]; then
    CP="$CP:./java/_"
else
    CP="$CP:$MODULES/java/_"
fi

elif [ -d "bower_components/decaf/java" ]; then CP="$CP:bowercomponents/decaf/java/" elif [ -d "/usr/local/decaf/java" ]; then CP="$CP:/usr/local/decaf/java/_" fi