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 to Xcode
Page Index Toggle Pages: 1
Processing to Xcode (Read 5713 times)
Processing to Xcode
Jan 25th, 2007, 3:30pm
 
I'm not sure if i'm in the right topic,

I would like to export some processing sketch to Xcode.

If i export the skectch and import the resulted class to xcode i can't make it to compile.

Many processing related commands are not recognized by xcode.

(I want to mix some processing and ObjC in the same app).

Someone knows ?
Re: Processing to Xcode
Reply #1 - Jan 25th, 2007, 3:42pm
 
yeah, i've been doing that a lot recently. you need to set your classpath properly:

make sure to include at least core.jar from (</ path / to / Processing.app / lib />) and maybe others if you need them ..

make sure you have all your libraries in your classpath too, if you use any.

btw. not sure what you are doing there, but the javabridge seems to be deprecated in os-x 10.4. see here:
http://www.cocoadev.com/index.pl?JavaBridge

good luck,
F
Re: Processing to Xcode
Reply #2 - Jan 25th, 2007, 4:21pm
 
I'll try this way.

Thank you.
Re: Processing to Xcode
Reply #3 - Jan 25th, 2007, 5:25pm
 
the easiest way to do it is to hit "export to application", which will bundle all the necessary jar files (core.jar and any libraries you've included) and you can pull the results into xcode. just leave out the jar for the sketch itself.

more important, however is that you'll see a (few?) .java files in the source folder, which are the .pde source code after it has been run through the preprocessor. this will take care of the syntax issues you're running into, although the .java file will need to be cleaned up, it's not really meant for humans.
Re: Processing to Xcode
Reply #4 - Jan 25th, 2007, 9:06pm
 
Fry,

I did what you told me and now i can compile and build the java code successfully (as xcode says).

But it doesn't start up when i try to launch it.

I have checked the built app /contents/resources/, there is only one file (myapp.jar) and it's only 4KB !

if i ungzip it, there is one file named myapp.class (which contains my written code) and one folder META-INF with the MANIFEST.MF

I've imported core.jar, video.jar ( i'm actually using video capture), myapp.jar, myapp.java from processing into my xcode project but it doesn't seem to include it in the building process.

I think i'm doing something wrong when i first have to create a new project in xcode.

What kind of project am i supposed to choose ?

I would like to be able to understand how to create a Java application (same as the exporting application's option in processing) with xcode.

Sorry, i know it doesn't sound like a processing issue, but i really like to use processing to create some part of my apps and just hope it won't be a problem to export the work that have been done with it. Smiley
Re: Processing to Xcode
Reply #5 - Jan 25th, 2007, 10:47pm
 
ok. here's how to do it for a simple app:

in xcode, choose new project. select "Java AWT Application" (or swing), give it a name and location.

remove About.java and PrefPane.java from the project. (we won't need them)

let your main java file contain:
Code:


// my project was called ProcessingXcodeExample,
// alter the code to match your project name.

import java.awt.*;
import javax.swing.*;

import processing.core.*;

public class ProcessingXcodeExample extends PApplet {

   public static void main ( String args[] ) {
// has to match your class name!
PApplet.main( new String[]{"ProcessingXcodeExample"} );

   }

   public void setup ()
   {

size( 100, 100 );
   }
   
   public void draw ()
   {

rect(random(width/2),random(height/2),10,10);
   }

}


make sure your class-name matches the string you pass to PApplet.main(), see above ...

now from the project menu choose: "Edit Active Target '...' "

in the window that opens, in the left menu choose "Search Paths"

on the right side click "Java Classes" and then the little + below to add:
in the file-chooser select the "lib" folder of your current processing version, click OK. then add "/core.jar" to the line, like:

$(SYSTEM_APPS_DIR)/Processing 0123/lib/core.jar

again from the right menu, choose "Pure Java Specific" from the "Info.plist Entries" tree. on the right side click the +. insert:

$JAVAROOT/core.jar

close the window.

( now you should be able to build this already )

to add the core.jar to the app (package) itself do:

right-click (or ctrl-click) on the (only) target, choose "Add > New Build Phase > New Copy Files Build Phase"

in the "General" tab, set "Destination" to "Java Resurces", close window.

from the "Project" menu choose "Add to Project", in the file-chooser select core.jar (/Applications/Processing XXX/lib/core.jar), click OK, click Add.

in the left menu, drag core.jar from the top project-tree into the "Copy Files" block down in your target. (to make it copy the file to inside your apps bundle).

( "Clean All" before if you build earlier )

ready, build and run!

F
Re: Processing to Xcode
Reply #6 - Jan 26th, 2007, 11:31am
 
Thank you very much for this tutorial, i knew i was missing something here.

I've followed it step by step and the resulting java app is bigger now (containing all the needed files to work).

The compilation process is successful without any warning or error.

The app won't start.

When i debug it, i get this error :

Quote:
[Session started at 2007-01-26 18:25:12 +0800.]
[JavaAppLauncher Error] CallStaticVoidMethod() threw an exception
Exception in thread "main" java.lang.UnsupportedClassVersionError: test (Unsupported major.minor version 49.0)

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:539)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)

at java.net.URLClassLoader.access$100(URLClassLoader.java:55)

at java.net.URLClassLoader$1.run(URLClassLoader.java:194)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:187)

at java.lang.ClassLoader.loadClass(ClassLoader.java:289)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)

at java.lang.ClassLoader.loadClass(ClassLoader.java:235)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:219)

at apple.launcher.LaunchRunner.loadMainMethod(LaunchRunner.java:55)

at apple.launcher.LaunchRunner.run(LaunchRunner.java:84)

at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)

at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)

test has exited with status 0.


The processing sketch is working but not when exported and built with xcode...

Any idea ?  
Re: Processing to Xcode
Reply #7 - Jan 26th, 2007, 2:51pm
 
sounds like you've compiled with java 1.5 and are trying to run the app with 1.4. check the settings in: Project -> Edit Active Target ... -> Java Compiler Settings. for me it reads 1.3 for both Target VM and Source Version. Now go down to "Pure Java Specific" in the "Info.plist Entries" and check what Target VM you have there ... the later one should be equal or higher that the one from the Compiler Settings.

F
Re: Processing to Xcode
Reply #8 - Jan 26th, 2007, 3:08pm
 
I've changed it to 1.3 or 1.4 and i get this now :

Quote:
[Session started at 2007-01-26 22:05:44 +0800.]
[JavaAppLauncher Error] CallStaticVoidMethod() threw an exception
Exception in thread "main" java.lang.NoClassDefFoundError: processing/core/PApplet
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at apple.launcher.LaunchRunner.loadMainMethod(LaunchRunner.java:55)
at apple.launcher.LaunchRunner.run(LaunchRunner.java:84)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)

test has exited with status 0.


Why is it so complicated to build a java app on Xcode ?

Processing is terribly simple for that job.
Re: Processing to Xcode
Reply #9 - Jan 26th, 2007, 3:57pm
 
this means that your app is missing the core.jar, so you have to check the copy files build phase and the settings in "active target settings -> info.plist -> pure java specific".

did you change your Configuration ("Debug"/"Release") maybe? your active target settings are in relation to that, so if you did the changes i mentioned and then change the configuration they might have been reversed. ... make sure all is set as i layed out above.

F
Re: Processing to Xcode
Reply #10 - Jan 26th, 2007, 8:09pm
 
I'm don't think it is a Processing issue,

so i decided to pm fjen.

If you guys think this topic is important, just let me know and i will post my results.

thx.
Re: Processing to Xcode
Reply #11 - Jan 26th, 2007, 9:16pm
 
Problem solved,

I was replacing $JAVAROOT/test.jar by $JAVAROOT/core.jar.

But in fact i would have to add it to the list.

Thanks a lot to fjen for his nice help.
Re: Processing to Xcode
Reply #12 - Jan 26th, 2007, 9:46pm
 
sure. you are welcome!
no need for another person to spend as many hours as i did trying to figure out xcode .. Smiley

F
Page Index Toggle Pages: 1