Compilation woes

Post Reply
mhetrick
Posts: 15
Joined: Sat Sep 25, 2010 7:08 pm

Compilation woes

Post by mhetrick » Sun Oct 10, 2010 2:16 am

Hi everybody,

I'm trying to compile and run my repository found here:
git://github.com/mhetrick/MH-ProcessingGUI-201b.git

I've included a bash script (be sure to use ./runMe.sh).

Here's the problem:
The .java files will compile into .class files. However, when it tries to run ProcessingGUI.class, it says that it cannot find the classdef. For the past two hours, I have tried all sorts of different options and folder structures within the bash scripts and directly through the terminal. I've gone on a mad Google dash, but that has only made me more confused.

This program ran perfectly in Eclipse, too. If needed, I could upload the entire project folder from Eclipse.

Any help would be appreciated.

Thanks,
Michael

angus
Posts: 43
Joined: Fri Apr 02, 2010 1:54 pm

Re: Compilation woes

Post by angus » Sun Oct 10, 2010 12:14 pm

Hi, if you look at your runMe bash script you will see that your classpath doesn't include the current directory. You need to specify every directory, even the one you are running from.

If you prepend your classpath with the "." to indicate the current directory, then your code will run fine. In your case:

Code: Select all

CLASSPATH='-cp .:lib/core.jar:lib/controlP5.jar'
Also, the main method of your ProcessingGUI class simply calls the PApplet's main method. This method expects the name of the class itself as the first argument. So in your case you'd pass "ProcessingGUI" as the first argument. Here are the edits I made to your runMe.sh script to get your code to run:

Code: Select all

#!/bin/bash
CLASSPATH='-cp .:lib/core.jar:lib/controlP5.jar'
javac $CLASSPATH *.java
java $CLASSPATH ProcessingGUI ProcessingGUI
HTH, Angus

mhetrick
Posts: 15
Joined: Sat Sep 25, 2010 7:08 pm

Re: Compilation woes

Post by mhetrick » Sun Oct 10, 2010 1:16 pm

Thank you!

I had tried variations of adding the working directory, including '. lib/...' and './lib/...', but not '.:lib/...'

Is there anyway to fix the source so that I wouldn't have to include ProcessingGUI as an argument to itself, or is that pretty standard as far as compiling Processing code in Java goes?

angus
Posts: 43
Joined: Fri Apr 02, 2010 1:54 pm

Re: Compilation woes

Post by angus » Sun Oct 10, 2010 2:53 pm

It's just a weird thing that Processing expects. You could hardcode it in your main method, or to save typing it twice you could use the $1 arguments as in the example script from the slides. -A

Post Reply