Forums > Java

Understanding Classpaths when creating externals in Eclipse w toxi Libs

Jan 11 2014 | 12:41 am


I am relatively inexperienced Java person, I usually work with Processing and avoid Eclipse, but I have created a few max externals previously. I haven’t, however, created any mxj objects that use external libraries.

I thought I followed the process correctly. I believe I have imported the libraries correctly into my java project in eclipse (toxi libs). I am not getting any errors, put it that way, but when I try and run the object in max I get this error.

java.lang.NoClassDefFoundError: toxi/physics2d/behaviors/ParticleBehavior2D

I believe this is a class path thing? Perhaps max doesn’t know where to find the verletphysics.jar ?

My class is below. Essentially I am wanting to use toxi physics to augment imput – at the present it is obviously not doing that – I was just testing the concept , which didn’t work!! The class is based on Toxi’s example.

Any help much appreciated.

import com.cycling74.max.*;

import toxi.geom.*;
import toxi.physics2d.*;
import toxi.physics2d.behaviors.*;

public class toxiPart extends MaxObject {


VerletPhysics2D physics;
AttractionBehavior mouseAttractor;
Vec2D mousePos;

public toxiPart(){

physics = new VerletPhysics2D();
physics.setWorldBounds(new Rect(0, 0, 200, 200));

//set attractor
mousePos = new Vec2D(100, 100);
// create a new positive attraction force field around the mouse position (radius=250px)
mouseAttractor = new AttractionBehavior(mousePos, 1000, 0.9f);

declareInlets(new int[]{ DataTypes.ALL, DataTypes.ALL});
declareOutlets(new int[]{ DataTypes.ALL, DataTypes.ALL});


void addParticle() {
VerletParticle2D p = new VerletParticle2D(Vec2D.randomVector().scale(5).addSelf(200 / 2, 0));
// add a negative attraction force field around the new particle
//physics.addBehavior(new AttractionBehavior(p, 20, -1.2f, 0.01f));

public void bang(){

if (physics.particles.size() < NUM_PARTICLES) {

mousePos.set((float)Math.random()*200, (float)Math.random()*200);

for (VerletParticle2D p : physics.particles) {



Jan 11 2014 | 9:17 am

You need to place verletphysics.jar into the Max classpath. On the Mac I believe this would be anywhere in the Max path – I put mine in "/Applications/Max 6.1/Cycling ’74/java/lib".

Jan 11 2014 | 11:18 am

Also if you want to create easily redistributable library of Java objects, your can build a jar-file with all dependencies in it and place this file to the "Cycling ’74/java/lib" directory.

Jan 12 2014 | 9:55 pm

Awesome, thanks for the replies – will get onto that tonight!


Viewing 4 posts - 1 through 4 (of 4 total)

Forums > Java