0
votes

I'm new to Weka. I downloaded it and can use the GUI interface, but I cannot figure out why I cannot run it from the command line (on a Mac OS X).

I'm in bash. When I do echo $PATH, I can see the path to weka.jar, but when I run

java -cp weka.jar weka.classifiers.functions.MultilayerPerceptron

Error: Could not find or load main class weka.classifiers.functions.MultilayerPerceptron Caused by: java.lang.ClassNotFoundException: weka.classifiers.functions.MultilayerPerceptron

Now, I go to the weka folders and I can see that I have classifiers/functions/ there, but the files inside are only htmls.

I also tried

java weka.core.WekaPackageManager

Error: Could not find or load main class weka.core.WekaPackageManager Caused by: java.lang.ClassNotFoundException: weka.core.WekaPackageManager

2

2 Answers

1
votes

You need to set the classpath

export CLASSPATH=/home/weka/weka.jar:$CLASSPATH
0
votes

I use this bash script to start wekafrom the command line:

#!/bin/bash
WEKA_HOME=/opt/smallapps/weka-3-9-1
export WEKA_JAR=$WEKA_HOME/weka.jar
export PATH=$WEKA_HOME:$PATH
CP="/usr/share/java/:/opt/dbvis9/jdbc/jtds/jtds.jar:/opt/database/sqlite/sqlite-
jdbc.jar:$WEKA_JAR"
echo "used CLASSPATH: $CP"
DIR=$WEKA_HOME
echo "changing to '$DIR'"
cd "$DIR"
export WEKA_HOME
# start small GUI Chooser, with 8GB of max memory
java -cp $CP -Xmx8092m weka.gui.GUIChooser &
#java -cp $CP -Xmx500m weka.gui.GUIChooser &

This also includes jarfiles with database drivers to the classpath

I think not all of these variables WEKA_HOME, WEKA_JAR, DIR etc are necessary, it's just what I'm using at the moment.