We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › processing, emacs, java: NoClassDefFoundError"
Page Index Toggle Pages: 1
processing, emacs, java: NoClassDefFoundError" (Read 2604 times)
processing, emacs, java: NoClassDefFoundError"
Dec 27th, 2009, 6:38pm
 
Hi. I'm trying to set up emacs to compile and run processing scripts.

I have set my classpath to point to the dir where core.jar lives.

My test scripts are returning the following error:

Code:

-*- mode: compilation; default-directory: "~/opt/processing-1.0.3/" -*-
Compilation started at Mon Dec 28 15:29:02

/home/mantis/opt/processing-1.0.3/java/bin/java -classpath "/home/mantis/opt/processing-1.0.3java/lib/rt.jar:/home/man\
tis/opt/processing-1.0.3java/lib/tools.jar:/home/mantis/opt/processing-1.0.3lib/antlr.jar:/home/mantis/opt/processing-\
1.0.3lib/core.jar:/home/mantis/opt/processing-1.0.3lib/ecj.jar:/home/mantis/opt/processing-1.0.3lib/jna.jar:/home/mant\
is/opt/processing-1.0.3lib/pde.jar" processing.app.Commander --sketch="/home/mantis/opt/processing-1.0.3/" --output="/\
home/mantis/opt/processing-1.0.3/output" --run
Exception in thread "main" java.lang.NoClassDefFoundError: processing/app/Commander
Caused by: java.lang.ClassNotFoundException: processing.app.Commander
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: processing.app.Commander.  Program will exit.

Compilation exited abnormally with code 1 at Mon Dec 28 15:29:02



Looks to my newbish eyes like java can't find a neccessary extension.
How can I fix this ?
Re: processing, emacs, java: NoClassDefFoundError"
Reply #1 - Dec 28th, 2009, 1:20am
 
Well, it looks like you try to run processing.app.Commander. Why?

Also I see paths like /home/mantis/opt/processing-1.0.3java/lib/rt.jar
You might be missing a slash after 1.0.3
Re: processing, emacs, java: NoClassDefFoundError"
Reply #2 - Dec 28th, 2009, 1:18pm
 
My understanding is that processing.app.Commander is a the java tool for running processing from the commandline, and that the emacs processing-mode invokes it to compile and run the contents of the buffer that it is being called on.

So, it looks like java, when being called by processing-mode can't find the Commander class.

I have created a classpath (initially my system didn't have or seem to need one) to point to processing's core.jar. Do I need to modify it further, so java can find Commander ?
Where is Commander anyway ?
Re: processing, emacs, java: NoClassDefFoundError"
Reply #3 - Dec 28th, 2009, 3:44pm
 
I think I see two problems here:

processing.app.Commander is the class that is invoked in order to process processing code.

I think that this is the important bit:

Code:
processing.app.Commander --sketch="/home/mantis/opt/processing-1.\
0.3/"


That string in the quotes should end with the name of the file being processed. The name of my file isn't being appended. So Commander isn't being given an input file.

The other problem is that processing.app.Commander can't be found by java.

Any idea how I can fix these things ?

Re: processing, emacs, java: NoClassDefFoundError"
Reply #4 - Dec 28th, 2009, 5:22pm
 
I have updated from processing 1.0.3 to 1.0.9
I am running processing on ubuntu linux.
(The linux version has java included)

The filename of the sketch is 'test'.
To compile, I am hitting C-c C-r.
I haven't made any modifications to the actual emacs-processing.el code.


The original error message I showed was generated when I tried to use compile using processing 1.0.3 on ubuntu linux.

To reduce initial path problems, I am running my test sketch in the same dir where processing is installed.

After updating, and trying to run my sketch using the same process from inside emacs, I get the same error:

Code:

-*- mode: compilation; default-directory: "~/opt/processing-1.0.9/" -*-
Compilation started at Tue Dec 29 14:21:30

/home/mantis/opt/processing-1.0.9/java/bin/java -classpath "/home/mantis/opt/processing-1.0.9ja\
va/lib/rt.jar:/home/mantis/opt/processing-1.0.9java/lib/tools.jar:/home/mantis/opt/processing-1\
.0.9lib/antlr.jar:/home/mantis/opt/processing-1.0.9lib/core.jar:/home/mantis/opt/processing-1.0\
.9lib/ecj.jar:/home/mantis/opt/processing-1.0.9lib/jna.jar:/home/mantis/opt/processing-1.0.9lib\
/pde.jar" processing.app.Commander --sketch="/home/mantis/opt/processing-1.0.9/" --output="/hom\
e/mantis/opt/processing-1.0.9/output" --run
Exception in thread "main" java.lang.NoClassDefFoundError: processing/app/Commander
Caused by: java.lang.ClassNotFoundException: processing.app.Commander
 at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: processing.app.Commander.  Program will exit.

Compilation exited abnormally with code 1 at Tue Dec 29 14:21:30



Re: processing, emacs, java: NoClassDefFoundError"
Reply #5 - Dec 28th, 2009, 6:08pm
 
I've been communicating with onmouse, the developer of processing-mode.

I've made an adjustment to my .emacs, to ensure that there is a trailing slash at the right place in a lisp expression that I created in order to follow the instructions in processing-mode.el's readme file.

I had ommitted the trailing slash. I have now corrected it thus:

(setq processing-location "/home/mantis/opt/processing-1.0.9/")

I now get the following error:
Code:

-*- mode: compilation; default-directory: "~/play/processing-1.0.9/" -*-
Compilation started at Tue Dec 29 14:56:34

/home/mantis/opt/processing-1.0.9/java/bin/java -classpath "/home/mantis/opt/processing-1.0.9/j\
ava/lib/rt.jar:/home/mantis/opt/processing-1.0.9/java/lib/tools.jar:/home/mantis/opt/processing\
-1.0.9/lib/antlr.jar:/home/mantis/opt/processing-1.0.9/lib/core.jar:/home/mantis/opt/processing\
-1.0.9/lib/ecj.jar:/home/mantis/opt/processing-1.0.9/lib/jna.jar:/home/mantis/opt/processing-1.\
0.9/lib/pde.jar" processing.app.Commander --sketch="/home/mantis/play/processing-1.0.9/" --outp\
ut="/home/mantis/play/processing-1.0.9/output" --run
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at processing.app.debug.Compiler.compile(Compiler.java:73)
at processing.app.Sketch.build(Sketch.java:1485)
at processing.app.Commander.<init>(Commander.java:203)
at processing.app.Commander.main(Commander.java:97)

Compilation exited abnormally with code 1 at Tue Dec 29 14:56:34


This is different. I might be getting somewhere.

However, if I search the *compilation* buffer for "test", I can't find it.
Could this mean that maybe my test sketch (titled test) is not being found?

This is the file I'm trying to run:
Code:

size(400, 400);
background(192, 64, 0);
stroke(255);
line(150, 25, 270, 350);


Just to see what would happen, I also tried to run another sketch, coded in the java style:
Code:

import processing.core.*;

public class MyProcessingSketch extends PApplet {

public void setup() {
size(200,200);
background(0);
}

public void draw() {
stroke(255);
if (mousePressed) {
line(mouseX,mouseY,pmouseX,pmouseY);
}
}
}



I got an indistinguishable error:
Code:

-*- mode: compilation; default-directory: "~/play/processing-1.0.9/" -*-
Compilation started at Tue Dec 29 15:06:55

/home/mantis/opt/processing-1.0.9/java/bin/java -classpath "/home/mantis/opt/processing-1.0.9/ja\
va/lib/rt.jar:/home/mantis/opt/processing-1.0.9/java/lib/tools.jar:/home/mantis/opt/processing-1\
.0.9/lib/antlr.jar:/home/mantis/opt/processing-1.0.9/lib/core.jar:/home/mantis/opt/processing-1.\
0.9/lib/ecj.jar:/home/mantis/opt/processing-1.0.9/lib/jna.jar:/home/mantis/opt/processing-1.0.9/\
lib/pde.jar" processing.app.Commander --sketch="/home/mantis/play/processing-1.0.9/" --output="/\
home/mantis/play/processing-1.0.9/output" --run
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at processing.app.debug.Compiler.compile(Compiler.java:73)
at processing.app.Sketch.build(Sketch.java:1485)
at processing.app.Commander.<init>(Commander.java:203)
at processing.app.Commander.main(Commander.java:97)

Compilation exited abnormally with code 1 at Tue Dec 29 15:06:56






Re: processing, emacs, java: NoClassDefFoundError"
Reply #6 - Dec 29th, 2009, 2:40am
 
Quote:
I had ommitted the trailing slash.
Yes, that's what I was pointing out...

Quote:
The filename of the sketch is 'test'.
It should be test.pde.

[EDIT]
Mmm, if I read correctly the code of Commander, you must not quote the paths given in --sketch and --output. (Which implies that such path must have no spaces in it.)
But the sketch path must include the name of the sketch.
In Processing tradition, you should have a folder of the name of the sketch with inside a .pde file of the same name:
Code:
--sketch=/home/mantis/play/processing-1.0.9/test 

Re: processing, emacs, java: NoClassDefFoundError"
Reply #7 - Dec 29th, 2009, 3:57pm
 
After an email conversation with the creator of processing-mode, I was alerted to where I was making the mistake:

I hadn't correctly followed the instructions from  the readme file included with processing-mode.el

procession requires preferences file to be in a directory called 'lib' to be in the same dir as the sketch file.

I had not done this.

Also, I hadn't suffixed my file name properly.

So, with omouses help, I managed to get my tests running.
Re: processing, emacs, java: NoClassDefFoundError"
Reply #8 - Dec 29th, 2009, 9:03pm
 
Ok. Solved it.

So this is what has to be done to create sketches:

* Enter processing's root dir.
* create a dir. Name it after your project
* create subdir 'lib'. Copy processing-1.0.9/lib/preferences.txt to it.
* create your sketch in you project subdirectory.

Right. Now I can exploring processing. And maybe growing some hair back.

Page Index Toggle Pages: 1