Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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]
      ]
    actionListener1 = JavaNew["com.wolfram.jlink.MathActionListener"];
    myWindow = JavaNew["javax.swing.JFrame","Snake"];
    myWindow@setSize[1200, 600]
    myWindow@setLocation[45, 100]
    buttonLoad = JavaNew["javax.swing.JButton", "Load Image"];
    buttonLoad@setSize[105,20]
    buttonLoad@setLocation[350,400]
    actionListener1@setHandler["actionPerformed", "ButtonClickHandler1"]
    buttonLoad@addActionListener[actionListener1]
    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]
    labelGradThre= JavaNew["javax.swing.JLabel", "gradient thresold:"];
    labelGradThre@setSize[100,20]
    ...
    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?

share|improve this question

1 Answer 1

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.