Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weka no main class found error

I installed the latest version of Weka on Windows

http://www.cs.waikato.ac.nz/ml/weka/

and I tried to run one of the weka features from the command line:

java weka.core.converters.TextDirectoryLoader -dir text_example > text_example.arff

which is a reference to this: http://weka.wikispaces.com/Text+categorization+with+WEKA

but then weka returns this error:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

Exception in thread "main" java.lang.NoClassDefFoundError: weka/core/converters/
TextDirectoryLoader
Caused by: java.lang.ClassNotFoundException: weka.core.converters.TextDirectoryL
oader
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: weka.core.converters.TextDirectoryLoader.  Progra
m will exit.

I already set the CLASSPATH environment variable to point to the weka jar.

What did I do wrong?

like image 793
kamikaze_pilot Avatar asked Jul 22 '26 19:07

kamikaze_pilot


1 Answers

The shell you run the command in apparently doesn't have the CLASSPATH environment variable set properly, otherwise the ClassNotFoundException wouldn't occur. As an alternative to the environment variable you can specify the classpath using the command line:

java -cp path/to/weka.jar weka.core.converters.TextDirectoryLoader -dir [...]

You can also check whether the environment variable is set correctly by executing echo %CLASSPATH% in the cmd shell.

like image 77
ahans Avatar answered Jul 25 '26 07:07

ahans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!