PDA

View Full Version : Problem in installing Weka in Linux



huajie.lee
11-21-2007, 07:11 PM
Hi there,

I just installed Weka Developer Version 3-5-6 and I followed the instructions.

First of all, I unzip the file and i execute the command :-

java -jar weka-3-5-6

However, I get the error message of:-

Failed to load Main-Class manifest attribute from weka-3-5-6


I would like to know what basically I missed out. Please advise!

***********************************************************************
Updated:-

The above steps I did the jar inside weka-3.5.6 folder itself.

I tried another steps. In weka-3.5.6 folder there are, weka.jar and weka.src.

Now I try to execute:-
java -jar weka.jar but have the below error message:-

Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
at java.awt.Toolkit.getDefaultToolkit(libgcj.so.7)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(libgcj.so.7)
at java.awt.Window.<init>(libgcj.so.7)
at java.awt.Frame.<init>(libgcj.so.7)
at javax.swing.JFrame.<init>(libgcj.so.7)
at weka.gui.LogWindow.<init>(Unknown Source)
at weka.gui.Main.<clinit>(Unknown Source)
at java.lang.Class.initializeClass(libgcj.so.7)
at java.lang.Class.forName(libgcj.so.7)
at gnu.java.lang.MainThread.run(libgcj.so.7)
Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit
at java.lang.Class.forName(libgcj.so.7)
at java.lang.Class.forName(libgcj.so.7)
at java.awt.Toolkit.getDefaultToolkit(libgcj.so.7)
...9 more

Please advise.maybe my steps were wrong.


-Jason

lucsorel
11-22-2007, 07:06 PM
Hi,


Hi there,

I just installed Weka Developer Version 3-5-6 and I followed the instructions.

First of all, I unzip the file and i execute the command :-

java -jar weka-3-5-6

The proper command would have been:
java -jar weka-3-5-6.jar (with ".jar" at the end)
but the exception below reveals that its your Java Virtual Machine (JVM) which triggered the problem. See below...


Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
at java.awt.Toolkit.getDefaultToolkit(libgcj.so.7)

As far as I know, Weka (and many Java applications using the AWT GUI library) require Sun's Java Virtual Machine (http://java.sun.com/javase/downloads/index.jsp) to work. And your exception shows that your "java -jar ..." command refers to GCJ's JVM. You can easily check what is your JVM by typing the following command in a console (terminal):
java -version
The solutions for you to run Weka on your Linux system (what distribution is it, by the way?):
remove GCJ's JVM and install Sun's JVM
leave GCJ's, install Sun'JVM, and force the "java" command to link to Sun's "java" instead of GCJ. Most presumably, "java" calls refers to a link located in the /usr/bin folder and links to GCJ's "java" command. Modify this symbolic link to link to something like /usr/lib/jvm/sun-java.../jre/bin/java
install Sun'JVM and use compete filepaths to execute the proper "java" command. Being in the weka folder you would type something like /usr/lib/jvm/sun-java.../jre/bin/java - jar weka_3-5-6.jar

You can also associate .jar files to Sun's "java" to make it more convivialIf you provide more information about your Linux distribution, I can provide easier (and more elegant) explanations and solutions.

I hope this helps.
Cordially, Luc

huajie.lee
11-23-2007, 12:14 AM
Hi there Luc,

Thanks for the reply. I checked with the version.

java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.0 (Ubuntu 4.1.0-1ubuntu8)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

And honeslty I am stunned on the steps you explained in previous reply. I would hope to have more complete command which I could understand and use to execute them. Thanks alot Luc.

By the way, I installed on my Desktop folder.

Desktop/weka-3-5-6

Thanks again.

Hear from you soon.

-Jason

Oh yeah. I forgot to mention my linux dist. is Ubuntu6.06.

Thanks.

lucsorel
11-23-2007, 05:20 AM
Hi Jason,


Hi there Luc,

Thanks for the reply. I checked with the version.

java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.0 (Ubuntu 4.1.0-1ubuntu8)
[...]

Thanks for checking. As you can see, It's not Sun's JVM which is called when you call "java -jar ..."

Thus, either Sun's JVM is not installed or it is overridden by GIJ.


And honeslty I am stunned on the steps you explained in previous reply. I would hope to have more complete command which I could understand and use to execute them. Thanks a lot Luc.
[...]
Oh yeah. I forgot to mention my linux dist. is Ubuntu6.06.

Well sorry about the former vague explanations. Depending on your Linux distribution, the description of the steps to solve your problem would have changed and I didn't want to start writing a long and boring catalog of explanations at that stage :)

Now that you said that your distribution is Ubuntu 6.06, it's a lot easier to help you:
just follow this guide: Installing Sun Java on Ubuntu (https://jdk-distros.dev.java.net/ubuntu.html). It is very well detailed and illustrated
check the output of "java -version". If it does not refer to Sun's JVM, it means that you probably need to remove GIJ (with the same tool -synaptic or adept- you used to install Sun's JVM)I hope these informations are less stunning!

Cordially, Luc

huajie.lee
11-25-2007, 06:38 PM
Hi Luc,

Some updated behavior I seen,

I managed to figure out the command based kind to execute Weka. I tried to input

java weka.associations.Apriori

This is the output i seen.(I am expecting error like No Training File given is been shown)

Exception in thread "main" java.lang.NoClassDefFoundError: weka/associations/Apriori


Please advise. Thanks.


-Jason
Hi Luc,

Thanks for the information, I managed to get the GCJ deleted and the Weka Java is able to load. I have two questions /doubt which I wish if you could help to clarify.


i) As far I know there are two different weka type. One is GUI which is the weka.jar when loaded. And the other one is command-based. I wonder how could I invoke command-based ones.

ii) I tried to load the weka.jar by java -jar weka.jar. However in the background of my terminal, it shows these errors:-

---Registering Weka Editors---
Trying to add JDBC driver: RmiJdbc.RJDriver - Error, not in CLASSPATH?
Trying to add JDBC driver: jdbc.idbDriver - Error, not in CLASSPATH?
Trying to add JDBC driver: org.gjt.mm.mysql.Driver - Error, not in CLASSPATH?
Trying to add JDBC driver: com.mckoi.JDBCDriver - Error, not in CLASSPATH?
Trying to add JDBC driver: org.hsqldb.jdbcDriver - Error, not in CLASSPATH?


I have tried to add the CLASSPATH of weka.jar in my .bashrc file.

Please advise what steps that I missed out ?


Thanks Luc. Hear from you soon.


-Jason

lucsorel
11-26-2007, 03:21 AM
Hi Jason,

Just to let you know, there is a mailing list dedicated to Weka users. Although I don't know what exactly are the different roles between this forum and the mailing list, the mailing list is pretty reactive. Have a look at the Weka mailing list info page (https://list.scms.waikato.ac.nz/mailman/listinfo/wekalist).

To increase the lisibility of this forum, it would be better to create a new thread whenever you want to discuss a new topic. Doing so, you will have more chances to draw the attention of people interested by the same topic: they may be looking for the same answer, or better, they may know the answer and see that you're lookiung for it ! :)


Hi Luc,
[...]
I tried to input java weka.associations.Apriori

This is the output i seen.(I am expecting error like No Training File given is been shown)
Exception in thread "main" java.lang.NoClassDefFoundError: weka/associations/Apriori
Please advise. Thanks.
I have never used the Apriori algorithm. This is definitely a question to ask to the mailing list I've talked before if nobody answers it on this forum.


Hi Luc,

Thanks for the information, I managed to get the GCJ deleted and the Weka Java is able to load. I have two questions /doubt which I wish if you could help to clarify.
Another very useful resource is the Weka FAQ webpage (http://weka.sourceforge.net/wiki/index.php/Frequently_Asked_Questions).


i) As far I know there are two different weka type. One is GUI which is the weka.jar when loaded. And the other one is command-based. I wonder how could I invoke command-based ones.
See this FAQ article: How do I use Weka from command line? (http://weka.sourceforge.net/wiki/index.php/Frequently_Asked_Questions#How_do_I_use_Weka_from_command_line.3F)


ii) I tried to load the weka.jar by java -jar weka.jar. However in the background of my terminal, it shows these errors:-

---Registering Weka Editors---
Trying to add JDBC driver: RmiJdbc.RJDriver - Error, not in CLASSPATH?
Trying to add JDBC driver: jdbc.idbDriver - Error, not in CLASSPATH?
Trying to add JDBC driver: org.gjt.mm.mysql.Driver - Error, not in CLASSPATH?
Trying to add JDBC driver: com.mckoi.JDBCDriver - Error, not in CLASSPATH?
Trying to add JDBC driver: org.hsqldb.jdbcDriver - Error, not in CLASSPATH?
I have tried to add the CLASSPATH of weka.jar in my .bashrc file.
Please advise what steps that I missed out ?

Don't worry too much, those are only warnings. Weka can also handle databases (like MySQL) thanks to the JDBC driver. When Weka starts, it checks if the JDBC driver is installed in your system (if the JDBC library is in your Java classpath). It seems that you have not installed the driver on your system, which is OK as long as you don't want Weka to load data from databases instead of files. If you want to know more about Weka and database connectivity, read this FAQ article: How do I connect to a database? (http://forums.pentaho.org/net/wiki/index.php/Frequently_Asked_Questions#How_do_I_connect_to_a_database.3F)

Cordially, Luc