windows Weka no main class found 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6514579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:14:31  来源:igfitidea点击:

Weka no main class found error

javawindowsexceptionmachine-learningweka

提问by kamikaze_pilot

I installed the latest version of Weka on Windows

我在 Windows 上安装了最新版本的 Weka

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

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

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

我尝试从命令行运行其中一项 weka 功能:

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

这是对此的参考:http: //weka.wikispaces.com/Text+categorization+with+WEKA

but then weka returns this error:

但随后 weka 返回此错误:

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.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.

我已经将 CLASSPATH 环境变量设置为指向 weka jar。

What did I do wrong?

我做错了什么?

回答by ahans

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:

您在其中运行命令的 shell 显然没有正确设置 CLASSPATH 环境变量,否则不会发生 ClassNotFoundException。作为环境变量的替代方案,您可以使用命令行指定类路径:

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.

也可以通过echo %CLASSPATH%在cmd shell中执行来检查环境变量是否设置正确。