How to Run Weka in Linux

So you’ve downloaded and installed Weka to your Linux system but when you click on Explorer or Experimenter you get this error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException ...

Just follow these steps to fix it:

  1. Create a “LookAndFeel.props” file in your home directory:
    Type:touch ~/LookAndFeel.props into system command line.
  2. Type this into the first line of the newly created LookAndFeel.props file:
    Theme=javax.swing.plaf.metal.MetalLookAndFeel
  3. Save the file and exit.
  4. Start WEKA and everything should now work.


Here’s a detailed version of the answer and explains a little bit of the why of this problem.

Here’s the full text of the original error:

chiefinnovator@MAIN1:~$ cd /home/chiefinnovator/weka/weka-3-4-8a/
chiefinnovator@MAIN1:~/weka/weka-3-4-8a$ java -jar weka.jar
 /usr/share/themes/Simple/gtk-2.0/gtkrc:46: Engine "thinice" is unsupported, ignoring
/usr/share/themes/Simple/gtk-2.0/gtkrc:53: Engine "redmond95" is unsupported, ignoring
/usr/share/themes/Simple/gtk-2.0/gtkrc:57: Engine "redmond95" is unsupported, ignoring
---Registering Weka Editors---
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at weka.gui.explorer.PreprocessPanel.addPropertyChangeListener(Unknown Source)
        at javax.swing.plaf.synth.SynthPanelUI.installListeners(SynthPanelUI.java:49)
        at javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:38)
        at javax.swing.JComponent.setUI(JComponent.java:652)
        at javax.swing.JPanel.setUI(JPanel.java:131)
        at javax.swing.JPanel.updateUI(JPanel.java:104)
        at javax.swing.JPanel.(JPanel.java:64)
        at javax.swing.JPanel.(JPanel.java:87)
        at javax.swing.JPanel.(JPanel.java:95)
        at weka.gui.explorer.PreprocessPanel.(Unknown Source)
        at weka.gui.explorer.Explorer.(Unknown Source)
        at weka.gui.GUIChooser$3.actionPerformed(Unknown Source)
        at java.awt.Button.processActionEvent(Button.java:388)
        at java.awt.Button.processEvent(Button.java:356)
        at java.awt.Component.dispatchEventImpl(Component.java:3955)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

[tags]weka, ubuntu, java, weka Exception, AWT-EventQueue-0, java.lang.NullPointerException[/tags]

2 Responses to “How to Run Weka in Linux”

  1. Anonymous says:

    Thanks! I have Ubuntu running on my iBook and this fixed Weka for me. Works beautifully. Cheers.

  2. Hi Anonymous, glad I could help.

    BTW on my second Ubuntu install I didn’t need to do this to get Weka to run.

    But I did have to install Sun’s Java:
    1. Add multiverse to repositories
    2. Install Sun’s Java from Synaptic
    3. Run: sudo update-alternatives –config java
    4. Select Sun java from the choices.