Could not find the main class

onyourmark
onyourmark used Ask the Experts™
on
Hello. I entered

;C:\Program Files (x86)\Java\jre6\bin to my Path environment variable. I am running Vista Ultimate on 64 bits.


Then I went to the command prompt and entered

java weka.core.converters.CSVLoader data.csv > data.arff

I get a message:


C:\Users\william>java weka.core.converters.CSVLoader data.csv > data.arff
Exception in thread "main" java.lang.NoClassDefFoundError: weka/core/converters/
CSVLoader
Caused by: java.lang.ClassNotFoundException: weka.core.converters.CSVLoader
        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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: weka.core.converters.CSVLoader.  Program will exi
t.

By the way, is there an easy way to copy from the Command Prompt?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you need to weka jar files/libraries into classpath...
for the classNotFoundException:
You need to make sure that you are executing that java command just outside the 'weka' folder.
I am assuming that
1) class files are generated (no compilation errors)
2) required jars/libs are in classpath



for e.g.,

java -classpath c:\temp\jar1.jar; weka.core.converters.CSVLoader data.csv > data.arff

where
c:\temp\jar1.jar --> replace with corrent location and name of weka jar file
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Author

Commented:
Hi. Thank you for the help. I am confused. Do I need to edit my Path variable in some other way or my CLASSPATH variable? I do have Java installed in C:\Program Files (x86)\Java\jre6\bin

and I do have Weka installed at
C:\Program Files (x86)\Weka-3-7
what does "C:\Program Files (x86)\Weka-3-7" includes?

Author

Commented:
Hi. Here is a screen shot
weka.jpg
i can see weka.jar file there. Is it added in the classpath?

Author

Commented:
In Environment Variables my CLASSPATH has
.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip

Author

Commented:
Here is my directory
java.jpg
Add "C:\Program Files (x86)\weka.jar" also in the classpath.

Author

Commented:
Hello. I added

then tried
java weka.core.converters.CSVLoader data.csv > data.arff

I get

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\william>java weka.core.converters.CSVLoader data.csv > data.arff
Exception in thread "main" java.lang.NoClassDefFoundError: weka/core/converters/
CSVLoader
Caused by: java.lang.ClassNotFoundException: weka.core.converters.CSVLoader
        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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: weka.core.converters.CSVLoader.  Program will exi
t.

C:\Users\william>

Author

Commented:
Sorry, I added

;C:\Program Files (x86)\weka.jar
try this
java -classpath "C:/Program Files (x86)/weka.jar" weka.core.converters.CSVLoader data.csv > data.arff

Author

Commented:
I get the same error
where is this classfile "weka.core.converters.CSVLoade" located?
Looks like
1) either we are not adding the right jar file in the classpath
2) or we are invoking the correct classfile

please check for the same and revert back

Author

Commented:
Hi. I am not sure how to locate that. I looked on the internet and find
http://weka.sourceforge.net/doc/weka/core/converters/CSVLoader.html
can you try this (both commands)

set CLASSPATH=%CLASSPATH%;C:\Program Files (x86)\weka.jar;
java weka.core.converters.CSVLoader data.csv > data.arff

Author

Commented:
Hi thanks. I tried that but I get the error on the second command.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial