在 Linux 上运行 WEKA
我已经下载并解压了以下WEKA版本weka-3-4-19。这是在Linux操作系统上。我希望通过命令行使用 WEKA,但是在执行时
java weka.classifiers.tress.j48.J48
我收到以下错误消息:
Exception in thread "main" java.lang.NoClassDefFoundError: weka/classifiers/tress/j48/J48
Caused by: java.lang.ClassNotFoundException: weka.classifiers.tress.j48.J48
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: weka.classifiers.tress.j48.J48. Program will exit.
有人可以帮我解决这个问题吗?谢谢。
编辑1:
在尝试 java -jar weka.jar 命令
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
at java.awt.Window.<init>(Window.java:432)
at java.awt.Frame.<init>(Frame.java:403)
at javax.swing.JFrame.<init>(JFrame.java:202)
at weka.gui.GUIChooser.<init>(GUIChooser.java:98)
at weka.gui.GUIChooser.main(GUIChooser.java:285)
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
编辑2:
在尝试java.weka.classifiers.trees.J48
Exception in thread "main" java.lang.NoClassDefFoundError: weka/classifiers/tress/J48
Caused by: java.lang.ClassNotFoundException: weka.classifiers.tress.J48
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: weka.classifiers.tress.J48. Program will exit.
编辑3:
{cslinux2:~/weka-3-4-19} echo $CLASSPATH
/people/cs/j/jld082000/weka-3-4-19/weka.jar:
{cslinux2:~/weka-3-4-19} java weka.classifiers.trees.J48
Weka exception: No training file and no object input file given.
General options:
-t <name of training file>
Sets training file.
-T <name of test file>
Sets test file. If missing, a cross-validation will be performed on the training data.
I have downloaded and unzipped the following WEKA version weka-3-4-19. This is on a linux operating system. I wish to use WEKA through the command line, however on executing
java weka.classifiers.tress.j48.J48
I get the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: weka/classifiers/tress/j48/J48
Caused by: java.lang.ClassNotFoundException: weka.classifiers.tress.j48.J48
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: weka.classifiers.tress.j48.J48. Program will exit.
Can someone help me resolve this? Thank you.
Edit1:
On trying the java -jar weka.jar command
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
at java.awt.Window.<init>(Window.java:432)
at java.awt.Frame.<init>(Frame.java:403)
at javax.swing.JFrame.<init>(JFrame.java:202)
at weka.gui.GUIChooser.<init>(GUIChooser.java:98)
at weka.gui.GUIChooser.main(GUIChooser.java:285)
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
Edit 2:
On trying java.weka.classifiers.trees.J48
Exception in thread "main" java.lang.NoClassDefFoundError: weka/classifiers/tress/J48
Caused by: java.lang.ClassNotFoundException: weka.classifiers.tress.J48
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: weka.classifiers.tress.J48. Program will exit.
Edit 3:
{cslinux2:~/weka-3-4-19} echo $CLASSPATH
/people/cs/j/jld082000/weka-3-4-19/weka.jar:
{cslinux2:~/weka-3-4-19} java weka.classifiers.trees.J48
Weka exception: No training file and no object input file given.
General options:
-t <name of training file>
Sets training file.
-T <name of test file>
Sets test file. If missing, a cross-validation will be performed on the training data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这仅仅意味着
weka.classifiers.tress.j48.J48
类不在 类路径。您可以使用-classpath
开关编写java
命令或设置 CLASSPATH(永久)变量。另一种方法是使用 @jberg 指出的-jar
开关。编辑:
正如我检查的那样(我从 该站点)在
weka.jar
包中肯定没有weka.classifiers.tress.j48.J48
类。您可能正在寻找:例如:
That simply means
weka.classifiers.tress.j48.J48
class is not in classpath. You can writejava
command with-classpath
switch or set CLASSPATH (permanent) variable. Another way is to use-jar
switch as pointed by @jberg.EDIT:
As I checked (I downloaded Weka 3-4-19 from that site) there is definitely no
weka.classifiers.tress.j48.J48
class inweka.jar
package. Probably you are looking for:For example:
这个“weka.classifiers.trees.j48.J48”是Weka文档中的一个拼写错误。应该是这样的:“weka.classifiers.trees.J48”
,而不是设置 $CLASSPATH 的替代方法只是放置:
另外,您可能想给它更多的内存来玩,以加快速度
:分类器(就像您尝试做的那样)您至少需要给它一些数据,这些数据必须已经转换为 ARFF 格式。
要对某些数据运行测试,请输入:
-t 用于训练文件。
参见这里:
Weka 入门
This "weka.classifiers.trees.j48.J48" is a typo in the Weka documentation. It's should be this: "weka.classifiers.trees.J48"
And instead of setting the $CLASSPATH the alternative is just to put:
Also, you might want to give it more memory to play with, to speed things up:
For running a classifier (like you are attempting to do) you need to at least give it some data, which must already be converted to ARFF format.
To run a test on some data enter:
-t is for training file.
See here:
Weka Primer
我没有在linux上使用过WEKA,但我认为它只是打包为jar文件,所以你想要:
java -jar weka.jar
你也可以使用weka源jar来使用通过将分类器包含在您自己的代码中,将其包含在您的构建路径中,就像其他 jar 一样。
I haven't used WEKA on linux, but I think it is just packaged as a jar file, so you want to:
java -jar weka.jar
You can also use the weka source jars to use the classifiers in your own code by including it in your build path like you would other jars.
我在 macOS 中运行 Linux Developer 版本。您可以复制下面的
.bash_profile
并根据您的需要进行修改。正如我在此处回答的那样,您可以将以下内容添加到您的
~/.bash_profile
中并刷新终端,您应该能够运行以下命令
I run the Linux Developer version in macOS. You can copy the
.bash_profile
below and modify to your needs.As I answered here, you can just put the following to your
~/.bash_profile
after this and refreshing the terminal, you should be able to run the following command