I want to run weka through the command line. I type in this command:
java -classpath weka.jar weka.classifiers.trees.J48 -t data/weather.arff -i
And I get this error
Exception in thread "main" java.lang.NoClassDefFoundError: weka/classifiers/tree
s/J48
Caused by: java.lang.ClassNotFoundException: weka.classifiers.trees.J48
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.classifiers.trees.J48. Program will exit.
My classpath variable is set to C:\Program Files\Weka-3-4\mysql-connector-java-3.1.8-bin.jar
Please let me know. Thanks.
Is your command shell in the same directory as weka.jar?
You get that message if java simply can't find weka.jar
go
dir weka.jar
and check that the command shell can find it.
If not, you need to cd to the folder that contains weka.jar
Or you could put the full path to weka.jar
$java -classpath /"your-weka-path"/weka.jar weka.classifiers.trees.J48 -t data/weather.arff -i
Related
I have a grammar P.g that until recently compiled quietly. Today when I type in the command prompt:
java -cp .;../antlr-3.5-complete.jar org.antlr.Tool P.g
(the grammar is in the folder gram, while antlr-3.5-complete.jar is in the parent folder. The prompt is placed in the folder gram.)
Generates the following errors:
warning(24): template error: context [/outputFile /parser /genericParser /region__/genericParser__m
embers] 32:3 no such property or can't access: org.antlr.tool.Grammar.indirectDelegates
Caused by: org.stringtemplate.v4.misc.STNoSuchPropertyException: no such property: org.antlr.tool.Gr
ammar.indirectDelegates
at org.stringtemplate.v4.misc.ObjectModelAdaptor.throwNoSuchProperty(ObjectModelAdaptor.java
:106)
at org.stringtemplate.v4.misc.ObjectModelAdaptor.lookupMethod(ObjectModelAdaptor.java:99)
at org.stringtemplate.v4.misc.ObjectModelAdaptor.getProperty(ObjectModelAdaptor.java:67)
at org.stringtemplate.v4.Interpreter.getObjectProperty(Interpreter.java:1158)
at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:210)
at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:703)
at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:635)
at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:703)
at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:635)
at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:703)
at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:635)
at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
at org.stringtemplate.v4.ST.write(ST.java:415)
at org.antlr.codegen.CodeGenerator.write(CodeGenerator.java:1296)
at org.antlr.codegen.Target.genRecognizerFile(Target.java:98)
at org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:459)
at org.antlr.Tool.generateRecognizer(Tool.java:696)
at org.antlr.Tool.process(Tool.java:509)
at org.antlr.Tool.main(Tool.java:98)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.stringtemplate.v4.misc.Misc.invokeMethod(Misc.java:218)
at org.stringtemplate.v4.misc.ObjectModelAdaptor.lookupMethod(ObjectModelAdaptor.java:84)
... 23 more
Caused by: java.lang.NullPointerException
at java.util.Objects.requireNonNull(Unknown Source)
at java.util.ArrayList.removeAll(Unknown Source)
at org.antlr.tool.CompositeGrammar.getIndirectDelegates(CompositeGrammar.java:226)
at org.antlr.tool.Grammar.getIndirectDelegates(Grammar.java:2722)
... 29 more
I did not change anything. From what all of these errors are due?
thank you very much
This happens using Java8, try to switch back to 7
The latest version of antlr 3.5 doesn't have this problem (3.5.2)
I've be struggling in debugging an install4j installer where I'm trying to introduce some complicated condition expression that is failing for some reason.
However when I try to use the debug_installer.sh script I get the following error:
java.io.FileNotFoundException: /Applications/install4j/resource/MessagesDefault (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at com.install4j.runtime.util.FileResourceBundle.<init>(Unknown Source)
at com.install4j.runtime.installer.frontend.Messages.createMessagesInternal(Unknown Source)
at com.install4j.runtime.installer.frontend.Messages.createMessages(Unknown Source)
at com.install4j.runtime.installer.frontend.Messages.getMessages(Unknown Source)
at com.install4j.runtime.installer.frontend.GUIHelper.showMessageInternal(Unknown Source)
at com.install4j.runtime.installer.frontend.GUIHelper.access$100(Unknown Source)
at com.install4j.runtime.installer.frontend.GUIHelper$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:682)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:643)
at java.awt.EventQueue$1.run(EventQueue.java:641)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:652)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
The file actually doesn't exist but I have no idea of what that file should contain. My install4j version is 4.2.8
In the debug installer start script, replace
-cp i4jruntime.jar:user.jar:user/*.jar
with
-cp 'i4jruntime.jar:user.jar:user/*'
Then it should work. This bug was fixed in 5.0.1.
I tried to run WLST (on Windows XP) but i always get java.lang.NoClassDefFoundError:
Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/wlst
Caused by: java.lang.ClassNotFoundException: weblogic.wlst
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: weblogic.wlst. Program will exit.
I tried to run *user_projects/domains/my_domain/bin/setDomainEnv.cmd* and *wlserver_10.3/server/bin/setWLSEnv.cmd* but without any success, i always get this NoClassDefFoundError when i run java weblogic.wlst myscript.py. What should i do?
To invoke WLST:
<WL_HOME>/common/bin/wlst.cmd myscript.py
Example:
C:/Oracle/Middleware/wlserver_10.3/common/bin/wlst.cmd myscript.py
The reason for your error is, weblogic.jar is not present in your CLASSPATH environment variable.
You don't need to do that every time you run the batch file.
From "My Computer" or "Computer" (depending on your version of Windows)
Click "Properties" or "System Properties"
Click "Advanced System Settings"
Add these user Environment Variables
WL_HOME=C:/Oracle/Middleware/wlserver_10.3
and
CLASSPATH=.;%WL_HOME%/server/lib/weblogic.jar
I compiled Infinispan quickstart and when I am trying to run I am getting following error
Exception in thread "main" java.lang.NoClassDefFoundError: Quickstart (wrong nam
e: org/infinispan/quickstart/embeddedcache/Quickstart)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
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: Quickstart. Program will exit.
I am following this tutorial.
https://github.com/infinispan/infinispan-quickstart/tree/master/embedded-cache
Though I am not using any IDE so that I can learn how maven works with infinispan. From command prompt prompt I am using this command To compile,
mvn clean compile dependency:copy-dependencies -DstripVersion
and then, to run,
java -cp target/classes:target/dependency/* Quickstart
It is compiling successfully.
I have tried to compile and then run the quickstart from within target directory where the class file is kept. But I am getting the same error class found .....
Thanks
Meena
Anyhelp will be appreciated.
Try running with
java -cp target/classes:target/dependency/* org.infinispan.quickstart.embeddedcache.Quickstart
I apologize, this seems like it is really simple but I can't seem to get it.
I've downloaded the Windows version of WEKA and installed it, but I can't seem to call it from the command line.
I've added a WEKAHOME environment variable, pointing to the directory containing weka.jar, and added that to my path with /weka.jar appended to it..
I am trying this command: java weka.classifiers.j48.J48 -t %WEKAHOME%/data/iris.arff
I then get the following error output.
Exception in thread "main" java.lang.NoClassDefFoundError:
weka/classifiers/j48/ J48 Caused by: java.lang.ClassNotFoundException:
weka.classifiers.j48.J48
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.classifiers.j48.J48. Program will exit.
What can I do to fix this?
It's because of this weka.classifiers.j48.J48, that is an error in the Weka documentation, it should be: weka.classifiers.trees.J48
(Note: the comments below are no longer relevant. The answer here works, and remember to set the classpath as Thomas Jungblut says below.)