# Wolfram Workbench problem with JLink

I'm working on Wolfram Workbench 2.0 and I'm creating a JLink Application project. Below there is the code:

    BeginPackage["Snake", {"JLink"}]
(* Exported symbols added here with SymbolName::usage *)
Begin["Private"]
(* Implementation of the package *)
InstallJava[]
ButtonClickHandler1[_]:=
JavaBlock[
filedialog = JavaNew["java.awt.FileDialog","Choose an image file"];
filedialog@setVisible[True]
]
myWindow = JavaNew["javax.swing.JFrame","Snake"];
myWindow@setSize[1200, 600]
myWindow@setLocation[45, 100]
actionListener1@setHandler["actionPerformed", "ButtonClickHandler1"]
buttonRun = JavaNew["javax.swing.JButton", "Run Snake"];
buttonRun@setSize[95,20]
buttonRun@setLocation[475,400]
cbShowAnim = JavaNew["javax.swing.JCheckBox", "Show animation"];
cbShowAnim@setSize[120,20]
cbShowAnim@setLocation[585,400]
labelImage = JavaNew["javax.swing.JLabel", "Snake"];
labelImage@setSize[1200,300]
labelImage@setLocation[0,0]
txtMaxiter = JavaNew["javax.swing.JTextField","300",3];
txtMaxiter@setSize[28,25]
txtMaxiter@setLocation[805,400]
labelMaxiter = JavaNew["javax.swing.JLabel", "Max. Iteration:"];
labelMaxiter@setSize[100,20]
labelMaxiter@setLocation[715,400]
...
JavaShow[myWindow]
End[]
EndPackage[]


Wolfram Workbench returns the following error:

The class com.wolfram.jlink.MathActionListener cannot be found.

Probably, Wolfram Workbench doesn't find the JLink package. How I can solve this problem?

-

First off, this is really just a warning, not an error. The package will still function normally because at run time the J/Link classes will be found. Workbench is just warning you that it cannot find them at development time.

You can avoid this problem if you check the "Add JLink.jar to the classpath" box when creating a new JLink project (I don't know why that isn't the default).

To fix an existing project showing this warning, edit the project's properties. In the properties dialog, go to Java Build Path/Libraries/Add External JARs and navigate to JLink.jar (\$InstallationDirectory/SystemFiles/Links/JLink/JLink.jar).

-