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 Libraries in non-p5 java
Page Index Toggle Pages: 1
Processing Libraries in non-p5 java? (Read 1238 times)
Processing Libraries in non-p5 java?
Dec 29th, 2005, 6:34am
 
I'd like to leverage the MaxLink library to communicate with MAX/MSP from a java application I'm writing that won't be run from within the P5 framework.   Is there a relatively easy way to integrate a library that's only available in assembled .jar with java w/o using the full P5 IDE?  Or should I just redesign to use P5?
Re: Processing Libraries in non-p5 java?
Reply #1 - Dec 29th, 2005, 1:19pm
 
In principle there's often no reason why a library shouldn't work with normal Java code, but since the BETA libraries are instantiated with a reference to a PApplet object you still need to have the Processing libraries:

Code:
public BoringLibrary(PApplet parent) {
this.parent = parent;
...
}


If the library doesn't actually use the PApplet object, you could pass it a null reference and use it as normal. I doubt you'll have much luck though.

You could try writing the person who wrote Maxlink and see if he is willing to give you the code. Ideally, library writers should release their source code under GPL so that it would be possible to recycle code for use outside of Processing as well.

Reinventing the wheel is the most tedious part of computational work. Being able to see the code also helps understanding the inner workings of the library, particularly for coders who are developing their work in Eclipse or other straight Java IDEs. My work certainly got easier when the Processing source became openly available.
Re: Processing Libraries in non-p5 java?
Reply #2 - Dec 29th, 2005, 3:22pm
 
lots of libraries don't actually need a PApplet object, so they may work just fine on their own. libraries needn't be anything special, their designation as "libraries" is more to do with having a consistent way to name the folders and files so that they work with the pde.
Re: Processing Libraries in non-p5 java?
Reply #3 - Dec 29th, 2005, 3:38pm
 
But a single call to PApplet.println(), PApplet.random() or any other convenience method will necessitate an actual PApplet instance. With Maxlink I would guess that it doesn't need an actual canvas, in which case one could instantiate a dummy PApplet to act as a host to the library, even if it never gets displayed.
Re: Processing Libraries in non-p5 java?
Reply #4 - Dec 29th, 2005, 4:53pm
 
Okay, I'll keep all of that in mind.

So, the next question is, how do I access a library from Java? I know I need to

import thelibrary.*;

or something to that effect, but where do I place the jar in the filesystem such that that works? Is it possible to import files from a jar in the same directory as the JAR your app is running in?  I know this is more a Java question than a p5 question, but bear with me please?
Re: Processing Libraries in non-p5 java?
Reply #5 - Dec 29th, 2005, 6:28pm
 
You will need to put it in your classpath, depending on your tool there are several ways of doing this. You also need to give your application access to the processing.core libraries so it can find PApplet etc.

Read REAS' post on integrating Eclipse with the Processing JARs for some good leads.

Good luck!
Page Index Toggle Pages: 1