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 › eclipse and ant
Page Index Toggle Pages: 1
eclipse and ant (Read 4508 times)
eclipse and ant
Feb 27th, 2008, 11:25pm
 
Ok..

Took the step of going to Eclipse for my Processing projects.
I still can't find a way to export either to an applet (or an exe). I've been scavenging the fora but I can't seem to find anything that works for me. I'm fairly new to eclipse (didn't even know what ant was), so maybe I'm missing something obvious.

I found this: http://www.andrewberman.org/projects/p5barebones/
which works almost, but ends in

BUILD FAILED
C:\werk\java\p5-barebones\build.xml:76: Error running javac.exe compiler

I only created a new java project,
unzipped the p5barebones into it,
added the external archive core.jar to get it running,
and pressed ALT SHIFT X, Q to run the ant build

running Eclipse 3.3.1.1 and Processing 0133
Re: eclipse and ant
Reply #1 - Feb 28th, 2008, 9:12am
 
Take  a look at the fatJar eclipse plugin (http://fjep.sourceforge.net/).
Re: eclipse and ant
Reply #2 - Feb 28th, 2008, 10:36am
 
Yeah, tried that already. But I probably went wrong somewhere because when I tried to run it as an applet the java console said: "load: class test_fat.class not found". When I ran it via cmd it said "Usage: PApplet <appletname>".
I only understand half of this stuff... what is a Manifest for instance? (F1 doesn't give any clues).

So after failing with FatJar I tried that Ant thing, since I thought it'd be nice to have the html etc generated (as P55 does).
Re: eclipse and ant
Reply #3 - Feb 28th, 2008, 9:35pm
 
Hey,

I was inspired by this post to work on an update to that P5Barebones project I started a little while ago. I managed to beautify the generated HTML and also integrate support for the excellent AppletObject project as well.

Here's the result:
http://www.andrewberman.org/projects/p5barebones/

Note that the page was generated by a single Ant command, and it's fully customizable, including OpenGL support!

Feel free to email me at gjuggler A@T gmail D0T com if you have any questions about this. I'm pretty confident that this framework is ideal for developing Processing applications for the web, and I'm willing to help people get over the learning curve towards using it.

Cheers,
 greg
Re: eclipse and ant
Reply #4 - Feb 29th, 2008, 9:22am
 
Well I got a running fatJar now because I forgot the all important Code:
public static void main(String args[]) {
PApplet.main(new String[] { "--present", "Test" });
}
Although I haven't been able to save images yet. And fatJar is not for applets is it?

I also want to get that ant working but I'm still doing something wrong.
Now on that P5Barbones page you state you have to get Apache Ant working in Eclipse. But when I installed Eclipse last week there were already tiny Ant icons running around the Eclipse interface. Does that mean the latest Eclipse comes with Ant?
Because when I run the P5Barebones Ant script it does do something. Here's the output:


Buildfile: C:\werk\java\p5-barebones\build.xml
init:
outputdebug:
clean:
loadjars:
build:
   [mkdir] Created dir: C:\werk\java\p5-barebones\build
   [javac] Compiling 1 source file to C:\werk\java\p5-barebones\build

BUILD FAILED
C:\werk\java\p5-barebones\build.xml:105: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre1.6.0_03"


Hmmm... looking at the error again. I recal seeing on the sun fora that you indeed need JDK instead of JRE (I'm always clearer in the morning).
I just went to sun and installed JDK, but now it ends in a less clear error:


   [javac] Compiling 1 source file to C:\werk\java\TestExport\build

BUILD FAILED
C:\werk\java\TestExport\build.xml:76: Error running javac.exe compiler


Maybe I need to restart my computer or something (kicking it might work).

-...-

No ... kicking it doesn't work either.
I noticed in the Eclipse console (in the single grey line above the output field) that it still tries to build with JRE (that should be JDK right?). I've setup the JAVA_HOME environment variable (in system properties) to the JDK root but somehow that doesn't work.

-...-

Read this thread: http://forum.java.sun.com/thread.jspa?threadID=440539&messageID=2519548
And got a succesfull build after adding the jdk tools.jar to the ant classpath:  Run - External Tools - Open External Tools Dialog

yay Smiley
Re: eclipse and ant
Reply #5 - Feb 29th, 2008, 10:46am
 
Hi Sjeiti,

Maybe this will help. I changed the 'javac' command in the build.xml file to the following:

<javac srcdir="${src}" destdir="${build}" source="${internal.javasource}" target="${internal.javasource}" compiler='modern' fork='yes'>
<classpath>
<fileset dir="${lib}" />
</classpath>
</javac>

Note the added 'compiler=modern' and 'fork=yes' parameters. If you either update your build.xml to follow this, or re-download the project from my site, then you can try out the updated command. This may be more reliable when running javac from Ant.

greg
Re: eclipse and ant
Reply #6 - Feb 29th, 2008, 11:13am
 
-sigh-

I don't know anymore... got one succesfull build then it failed again. Tried the solution above, got another 'Error running javac.exe compiler'.

I'm gonna give up for now (I'll try again later).
I hate computers.
Re: eclipse and ant
Reply #7 - Feb 29th, 2008, 1:44pm
 
Heh, yeah this stuff can be frustrating sometimes.

A few things to try:

1. In the build.xml file, try changing the "fork=yes" to "fork=no"
2. Make sure your JAVA_HOME environment variable is set to the location of your latest JDK.

http://www.atlassian.com/software/jira/docs/latest/java.html

3. Try separately installing Ant and running the ant command ("ant build.xml") from the command prompt.

Good luck!
Re: eclipse and ant
Reply #8 - Feb 29th, 2008, 2:52pm
 
Frustrating yes, but I just got ssh svn working in Eclipse (and I don't know what I'm doing) so Ant should be possible to.

...and it is.
I'm on another machine here so I went through the steps again
- installed JDK
- set JAVA_HOME
- added tools.jar
- set fork to 'no' (in P5Barebones project)

...and it works!!!
Now let's just hope it will work at the other machine as well (this: Vista, other: XP).


Thanks for the help!


ps: What's a fork? What have forks got to do with ants?
Re: eclipse and ant
Reply #9 - Feb 29th, 2008, 6:09pm
 
A fork is an eating utensil, and ants are best served fried, sometimes dipped in chocolate.

... Really, the fork parameter just tells Ant whether or not to create a new JVM process for running the compiler command. When fork is set to false, the compiling is done within the same JVM in which Ant is running; when fork is true, a new process is "forked" for the task. I assume there are some cases (for example, when running parallel tasks) when forking is beneficial.

Do let me know if you have any bugs or ideas for addition to the build.xml file.

Cheers
 greg
Re: eclipse and ant
Reply #10 - Mar 1st, 2008, 12:07am
 
Well, since you asked. I always like to keep my root clean: put all css and style related images in a subfolder style, put all js and java in a subfolder scripts, put all downloads in a subfolder data. etc... but that's just personal preference.

I did notice that when you set opensource, sourcezip, projectzip and standalonezip to false it will still show up as a (broken) hyperlink in the html. Tried surrounding that block with an if/then statement but that of course leaves the ${..} stuff on the page.

Also I wouldn't say <div id="header"> but use <h1>, and maybe replace the <img> with a h1{backround-image:url(icon-sm.png);padding-left:40px} in the css.

For footer2 it might also be nice to give people the option in build.properties to list the used libraries, code and/or thanks to. Should you do that it would be better to change that div to an unordered list (list-style:none).

And maybe a bit of a pain in the ass. But why not delete only the stuff you put in. I got the applet to output directly to a subfolder in my apache httpdocs. Now the applet I'm building will save images to a folder but when I run ant the contents of all the subfolders will get deleted.

Oh.. one more Smiley
When I change my project.name to something with a spaces (or &nbsp;) the applet init fails with a ClassNotFoundException.  My guess is jars with spaces in the filename don't load, a find/replace space to underscore for the jar filename would fix it.
Re: eclipse and ant
Reply #11 - Mar 2nd, 2008, 9:32pm
 
Hi Sjeiti,

Thanks for your comments and ideas. I've got enough in me for one more major update, and it's now up on the andrewberman site. I took many of your suggestions into account, though at this point I can't really remember which ones Tongue .

I'm particularly happy about how well the Yahoo! UI widgets integrated with Processing applets; see

http://www.andrewberman.org/projects/p5barebones/yui-index.html

and click "Load Applet Panel" for an example.

Cheers,
 greg
Re: eclipse and ant
Reply #12 - Dec 30th, 2008, 2:09am
 
Hi,

My end objective is to work in eclipse and be able to easily build stand-alone executable .jar's as well as applets. Using the p5 Barebones I was able to compile his ANT build fine, and this appears to have created an applet.

Does this p5 Barebones allow me to build the stand-alone jar as well? It does not appear to have created one. How can I create a stand-alone using ANT?

thanks,
-Kyle
Page Index Toggle Pages: 1