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.
IndexProcessing DevelopmentCore,  Processing Development Environment (PDE) › Getting a working copy of processing.app.Commander
Page Index Toggle Pages: 1
Getting a working copy of processing.app.Commander (Read 4563 times)
Getting a working copy of processing.app.Commander
Oct 22nd, 2008, 5:26am
 
Hello All,
I'd like to start working on a vim script for command-line processing.  As per the instructions in the release notes for 153, I checked out the source, built it with out any problems (under cygwin), and executed the ./dist.sh script in build/cmd.  The resulting file tree is below.  I was expecting more jar files; I got jna, antlr, and ecj, but no pde.jar (which, I discovered using jar -tf was the jar containing processing.app.Commander).  Any hints?  Note that the 'processing' files below are more like stubs than real files; each is less than a kb...

C:.
|   dist.sh
|   processing-cmd-0154.zip
|
+---.svn
+---dist
|   |   processing
|   |
|   \---.svn
|      
\---processing-cmd-0154
   |   processing
   |   revisions.txt
   |
   +---lib
   |   |   about.jpg
   |   |   antlr.jar
   |   |   buttons.gif
   |   |   ecj.jar
   |   |   icon.gif
   |   |   jna.jar
   |   |   keywords.txt
   |   |   preferences.txt
   |   |   resize.gif
   |   |   tab-sel-left.gif
   |   |   tab-sel-menu.gif
   |   |   tab-sel-mid.gif
   |   |   tab-sel-right.gif
   |   |   tab-unsel-left.gif
   |   |   tab-unsel-menu.gif
   |   |   tab-unsel-mid.gif
   |   |   tab-unsel-right.gif
   |   |
   |   \---export
   |       |   applet-opengl.html
   |       |   applet.html
   |       |   application.exe
   |       |   loading.gif
   |       |   template.plist
   |       |
   |       \---skeleton.app
   |           \---Contents
   |               |   PkgInfo
   |               |
   |               +---MacOS
   |               |       JavaApplicationStub
   |               |
   |               \---Resources
   |                   |   sketch.icns
   |                   |
   |                   \---Java
   \---libraries
       |   howto.txt
       ...
Re: Getting a working copy of processing.app.Comma
Reply #1 - Oct 22nd, 2008, 11:13pm
 
Hello all, I've just recompiled, and the output of build/cmd/dist.sh is as follows; not innocuous as I found before.  Tracking this down ...

/c/processing_dev/processing/build/cmd
Myer@Presta> ./dist.sh
Creating command-line distribution for revision 0154...
cp: cannot stat `../../xml': No such file or directory
cp: cannot stat `../../candy': No such file or directory
cp: cannot stat `../linux/work/lib/pde.jar': No such file or directory
cp: cannot stat `../linux/work/lib/core.jar': No such file or directory
Creating tarball and finishing...

Re: Getting a working copy of processing.app.Comma
Reply #2 - Oct 22nd, 2008, 11:19pm
 
Just for the heck of it, I tried building for linux on cygwin, to get the errors that had to do with the linux jars.  Of course it didn't work:

/c/processing_dev/processing/build/linux
Myer@Presta> ./make.sh
Setting up directories to build for Linux...
Extracting examples...
Extracting reference...
Extracting JRE...
Building processing.core
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file
Building PDE for JDK 1.5...
Building antlr grammar code...
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file
../../../../build/linux/work/java/bin/java: ../../../../build/linux/work/java/bin/java: cannot execute binary file
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file

zip error: Nothing to do! (try: zip -0rq ../lib/pde.jar . -i .)
Building serial library...
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file
Building net library...
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file
Building OpenGL library...
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file
Building PDF library...
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file
Building DXF library...
../build/linux/work/java/bin/java: ../build/linux/work/java/bin/java: cannot execute binary file

Done.

Re: Getting a working copy of processing.app.Comma
Reply #3 - Oct 22nd, 2008, 11:26pm
 
So here's my complete command line output from the build process.  Am I doing anything wrong?  Is there any documentation on this other than in the version history?

/c/processing_dev/processing/build/windows
Myer@Presta> ./make.sh
Building processing.core...
Building PDE for JDK 1.5
ANTLR Parser Generator   Version 2.7.7 (2006-11-01)   1989-2005
ANTLR Parser Generator   Version 2.7.7 (2006-11-01)   1989-2005
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Building serial library...
Building net library...
Building video library...
Found Quicktime 7 installation
Building OpenGL library...
Building PDF library...
Building DXF library...

Done.

/c/processing_dev/processing/build/windows
Myer@Presta> cd ../cmd/; ./dist.sh
Creating command-line distribution for revision 0154...
cp: cannot stat `../../xml': No such file or directory
cp: cannot stat `../../candy': No such file or directory
cp: cannot stat `../linux/work/lib/pde.jar': No such file or directory
Creating tarball and finishing...

Re: Getting a working copy of processing.app.Comma
Reply #4 - Oct 23rd, 2008, 7:06am
 
Ok, I've figured out where a few of the problems were. In cmd/build.sh, it was trying to figure out what platform by validating 'uname' against "Cygwin," when my Cygwin's 'uname', when actually:

/c/processing_dev/processing/build/cmd
Myer@Presta> uname            
CYGWIN_NT-5.1

So I changed the dist.sh file to check for that name.  Someone more regexy or scripty than me can come up with a more permanent solution; I'm just getting used to the open source world.  Anyway, so now, this is the output of dist.sh:  a little better, but command-line-friendly processing still doesn't build.  

/c/processing_dev/processing/build/cmd
Myer@Presta> ./dist.sh
Creating command-line distribution for revision 0154...
cp: cannot stat `../../xml': No such file or directory
cp: cannot stat `../../candy': No such file or directory
Creating tarball and finishing...

Re: Getting a working copy of processing.app.Comma
Reply #5 - Oct 23rd, 2008, 7:28am
 
Ok, I read in the todo that candy was removed, so why the heck is cmd/dist.sh checking for it?  I commented both that and the xml line out.  That removed the errors, but still no processing app, just the empty, soulless processing file.  Or at least, I thought it was empty and soulless until I cat'd it and found out (surprise!) that it was a shell script.  I guess even on cygwin I expect shell scripts to have an .sh extension.  

So then I tried processing-cmd-0154/processing --help, and that did nothing except load processing (without printing help, which, according to the javadoc, it should: http://dev.processing.org/reference/everything/javadoc/processing/app/Commander.html).  Upon looking more at the shell script, it seemed like my command line arguments must not have been getting through, so I uncommented the "unsafe" run: (java processing.app.Commander $*) and commented out the other.  Even then, the --help switch did nothing.  
Re: Getting a working copy of processing.app.Comma
Reply #6 - Oct 23rd, 2008, 8:01am
 
So I renamed the script "processing.sh", and called it the way you would normally call a script: ./processing.sh --help.  That gave me the juicy bits:

java.lang.NoClassDefFoundError: processing/app/Commander
Caused by: java.lang.ClassNotFoundException: processing.app.Commander
       at java.net.URLClassLoader$1.run(Unknown Source)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(Unknown Source)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: processing.app.Commander.  Program will exit.
Re: Getting a working copy of processing.app.Comma
Reply #7 - Oct 23rd, 2008, 8:18am
 
I've (personally) had a hard time doing java development on cygwin because of the difference in the environment variables, directory names, and in general inelegance of using a windows-compiled java binary in a linux environment.  As a result, even when I'm in bash, I use ant for java dev.  So I ditched the magical shell script that I worked so hard for, and wrote the following build.xml for ant:

<project name="ProcessingBuild" default="dist" basedir=".">

   <description>
       ProcessingBuild
   </description>
   <property name="processingDir" location="c:\Program Files\processing-0152\"/>
   <!--
   <property name="processingDir" location="C:\processing_dev\processing\build\windows\work\java\bin"/>
   -->
   <property name="processingJars"  value="lib"/>
   <property name="processingJavaJars" value="java\lib\"/>

   <target name="processing" description="run the pde">
       <java classname="processing.app.Commander"
             fork="true"
             dir="${processingDir}\${processingJars}">

             <classpath>
                 <fileset dir="${processingDir}\${processingJars}">
                     <include name="**/*.jar"/>
                 </fileset>
                 <fileset dir="${processingDir}\${processingJavaJars}">
                     <include name="**/*.jar"/>
                 </fileset>
             </classpath>

             <arg line="--help"/>
         </java>
     </target>
</project>

while this isn't completely done yet, it succeeds in loading all the junk together, and generating the right output (yay!):

ant processing
Buildfile: build.xml

processing:
    [java] Processing 0152 Beta rocks the console.
    [java]
    [java] --help               Show this help text.
    [java]
    [java] --sketch=<name>      Specify the sketch folder (required)
    [java] --output=<name>      Specify the output folder (required and
    [java]                      cannot be the same as the sketch folder.)
    [java]
    [java] --preprocess         Preprocess a sketch into .java files.
    [java] --build              Preprocess and compile a sketch into .class files.
    [java] --run                Preprocess, compile, and run a sketch.
    [java] --present            Preprocess, compile, and run a sketch full screen.
    [java]
    [java] --export-applet      Export an applet.
    [java] --export-application Export an application.
    [java] --platform           Specify the platform (export to application only).
    [java]                      Should be one of 'windows', 'macosx', or 'linux'.
    [java]
    [java] --preferences=<file> Specify a preferences file to use (optional).

BUILD SUCCESSFUL
Total time: 1 second
Re: Getting a working copy of processing.app.Comma
Reply #8 - Oct 23rd, 2008, 8:57am
 
I've been trying unsuccessfully to get it to launch a sketch folder.  The wording in the commander class really needs to be revised to make it more specific about what paths need to be specified where on the parameter path.  I figured out by trial and error that they didn't want the folder that contained all my processing sketches, they wanted a folder with the same name as the processing sketch that I wanted to run.  Now I'm trying to figure out how to supply it with the path to the preferences:

Buildfile: build.xml

processing:
    [echo] java --sketch=C:\cygwin\home\Myer\java\src\com\myernore\processing\sketches\first --output=C:\cygwin\home\Myer\java\src\com\myernore\processing\output --run
    [java] java.io.FileNotFoundException: c:\Program Files\processing-0152\lib\lib\preferences.txt (The system cannot find the path specified)
    [java]     at java.io.FileInputStream.open(Native Method)
    [java]     at java.io.FileInputStream.<init>(FileInputStream.java:106)
    [java]     at processing.app.Base.getStream(Base.java:1572)
    [java]     at processing.app.Preferences.init(Preferences.java:155)
    [java]     at processing.app.Commander.<init>(Commander.java:177)
    [java]     at processing.app.Commander.main(Commander.java:95)
    [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 9 seconds
Re: Getting a working copy of processing.app.Comma
Reply #9 - Oct 23rd, 2008, 9:27am
 
Everything is working.  What follows is a description of what I had to do.  I didn't need to build in a special way to get command line functionality, despite what http://dev.processing.org/reference/everything/javadoc/processing/app/Commander.html said.  I also found that that document said that the preferences file is optional, but in practice it will abort if preferences.txt is not in your path.  To get around this, I had ant start the jvm in processing's directory.  Chances are, the build.xml will work for you, as long as you change the value of the "processingDir" property to the location of the processing directory on your system.  All arguments to the Commander class are supplied in args.properties all on one line; they are imported into build.xml under the "args" property, and ran with java.  I chose to keep args to Commander class in this file, because I plan to programmatically change the contents of this file.  

HOPE THIS HELPS!!
Myer

/////////////////////////////////////////////////
/////////////////file 1: first.pde ///////////////
/////////////////////////////////////////////////
void setup()
{
   size( 300, 300 );
}

void draw()
{
   background( random( 255 ), (int)random( 255 ), random( 255 ) );
}

/////////////////////////////////////////////////
/////////////////// file 2: build.xml ///////////
/////////////////////////////////////////////////
<project name="ProcessingBuild" default="dist" basedir=".">

   <description>
       ProcessingBuild
   </description>

   <property name="processingDir" location="c:\Program Files\processing-0152\"/>
   <property name="processingJars"  value="lib"/>
   <property name="processingJavaJars" value="java\lib\"/>
   <property file="args.properties"/>

   <target name="processing" description="run the pde">
       <echo message="java ${args}"/>
       <java classname="processing.app.Commander"
             fork="true"
             dir="${processingDir}">

             <classpath>
                 <fileset dir="${processingDir}\${processingJavaJars}">
                     <include name="**/*.jar"/>
                 </fileset>
                 <fileset dir="${processingDir}\${processingJars}">
                     <include name="**/*.jar"/>
                 </fileset>
             </classpath>
             <arg line="${args}"/>
         </java>
     </target>
</project>

/////////////////////////////////////////////////
/////////////////// file 2: args.properties /////
/////////////////////////////////////////////////

args=--sketch=C:\\cygwin\\home\\Myer\\java\\src\\com\\myernore\\processing\\sket
ches\\first --output=C:\\cygwin\\home\\Myer\\java\\src\\com\\myernore\\processing\\output --run

/////////////////////////////////////////////////
/////////////////// part 3: command line in /////
/////////////////////////////////////////////////
~/java/src/com/myernore/processing
Myer@Presta> ant processing
Buildfile: build.xml

processing:
    [echo] java --sketch=C:\cygwin\home\Myer\java\src\com\myernore\processing\sketches\first --output=C:\cygwin\home\Myer\java\src\com\myernore\processing\output --run

BUILD SUCCESSFUL
Total time: 6 seconds
Page Index Toggle Pages: 1