lundi 20 avril 2015

Setting Java CLASSPATH doesn't work but -cp does

So, here's the problem I encountered. I wrote a simple .bat file to run weka on some data sets I had but Java recently updated itself and it stopped working. My old code was this:

@ECHO OFF

SET CLASSPATH = "C:\Program Files (x86)\Weka-3-6\weka.jar"
FOR /r %%I IN (*.arff) DO (
    ECHO Running %%~nI.arff
    java weka.classifiers.meta.FilteredClassifier -t %%~nI.arff -F "weka.filters.unsupervised.attribute.Remove -R 1,3,4,5" -W weka.classifiers.functions.LinearRegression -x 10 >> results.txt
    ECHO >> results.txt
)

This worked before and it did the job I asked of it. However, after the java update, I kept getting the error "Could not find or load main class weka.classifiers.meta.FilteredClassifier". I couldn't figure it out because the directory names and class names were exactly correct. So, I changed the code to this:

@ECHO OFF

SET CLASSPATH = "C:\Program Files (x86)\Weka-3-6\weka.jar"
FOR /r %%I IN (*.arff) DO (
    ECHO Running %%~nI.arff
    java -cp "C:\Program Files (x86)\Weka-3-6\weka.jar" weka.classifiers.meta.FilteredClassifier -t %%~nI.arff -F "weka.filters.unsupervised.attribute.Remove -R 1,3,4,5" -W weka.classifiers.functions.LinearRegression -x 10 >> results.txt
    ECHO >> results.txt
)

And it worked again. Can anyone tell me why this happened? The only thing I can think of is that the Java update isn't playing nice with itself somehow. Any insight would be appreciated thanks.

Aucun commentaire:

Enregistrer un commentaire