"workspace" error in Java

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

"workspace" error in Java

Darius
Hi guys,


Trying to get a simple backprop NN to work in a java class using Simbrain.jar as a library, but coming up against a problem.

Many of the example .bsh scripts use functions like...
workspace.clearWorkspace();
networkComponent = new NetworkComponent("foo");

but I'm getting some "cannot be resolved" errors when trying to compile, and I seem to be missing how "workspace" operates - like whether it needs initialisation or support files?


Thanks in advance! :-)
Reply | Threaded
Open this post in threaded view
|

Re: "workspace" error in Java

jyoshimi
Administrator
I gather from the github discussion that this got resolved, but let me know if not.
Reply | Threaded
Open this post in threaded view
|

Re: "workspace" error in Java

Darius
This post was updated on .
Hi Jeff, thanks for the pointer.


Went through the issues on GH - This seems to be a similar problem to mine: (is it the one you refer to?)
https://github.com/simbrain/simbrain/issues/1
Seems you fixed it by sending him some working Workspace files!

I haven't managed to get Log4J working yet, so the best error I can give you is
        "java.lang.NoClassDefFoundError: org/simbrain/workspace/WorkspaceComponent"
Then again, I'm probably just doing something horribly naive.


Eternally impressed,
Darius
Reply | Threaded
Open this post in threaded view
|

Re: "workspace" error in Java

jyoshimi
Administrator
Hi again Darius

Oh I was thinking of something else.

Below is an example that worked for me. Hope it helps!

- Jeff

import org.simbrain.network.core.*;
import org.simbrain.network.*;
import org.simbrain.workspace.*;

//
// Assumes this file is named TestWorkspace.java and is in the same directory as Simbrain.jar
// To compile: javac -classpath Simbrain.jar TestWorkspace.java
// To run: java -classpath Simbrain.jar:. TestWorkspace
//
public class TestWorkspace{
        public static void main(String[] args) {
                Workspace workspace = new Workspace();
                NetworkComponent networkComponent = new NetworkComponent("Test Network");
            workspace.addWorkspaceComponent(networkComponent);
            Network network = networkComponent.getNetwork();
            for (int i = 0; i < 100; i++) {
                Neuron neuron = new Neuron(network, "DecayRule");
                neuron.setUpperBound(10);
                network.addNeuron(neuron);
            }
                System.out.println(network);
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: "workspace" error in Java

Darius
Hi Jeff,

That's brilliant, thanks - taking a step back to see it simply was great.

Thanks again for your help and the awesome software.