Processing Notes
|
Create an empty Maven project
- Create an empty Maven project to import a Processing project into:
(please note it scrolls off to the right, make sure to highlight it all)
mvn archetype:create -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=org.processing.sketch -DartifactId=ExampleSketch
- The project name in this example is ExampleSketch.
- Copy the java classes into ExampleSketch\src\main\java.
Example pom.xml for a Processing project
- Replace the contents of new pom.xml with this:
(please note it scrolls off to the right, make sure to highlight it all)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.processing.sketch</groupId> <artifactId>ExampleSketch</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>ExampleSketch</name> <dependencies> <dependency> <groupId>org.processing</groupId> <artifactId>core</artifactId> <version>1.0.3</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorId>jar-with-dependencies</descriptorId> <archive> <manifest> <!-- NOTE: If you change the name of your class, change it here too. --> <mainClass>ExampleSketch</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
|
Import into Eclipse
- Creating the maven 2 project makes it trivial to import the project into Eclipse (and other IDEs).
- From the project root run:
mvn eclipse:eclipse
- In Eclipse select File > Import, choose Existing Projects into Workspace and click Next.
- Browse to the project root directory and click OK.
- The Projects box should have your project listed. (If not confirm that there is .classpath and .project file in your project root and that there isn't a project with the same name already in your workspace.)
- Click Finish.
Packaging code into Executable jar
- Finally maven 2 makes it easy to create a distributable executable jar.
- From the project root type:
mvn install
- In the target directory there should be a file called ExampleSketch-1.0-SNAPSHOT-jar-with-dependencies.jar.
- To run the jar type:
java -jar ExampleSketch-1.0-SNAPSHOT-jar-with-dependencies.jar
Processing Windows without Java - expert
- The download does not include java and is about half the size.
- The expert download allows the use of Java libraries compiled against java 1.5 and 6.
- The startup is a little tricky, here is my startup script:
cd C:\dev\tools\processing-1.0.3-expert-Wrj4P5 C:\dev\tools\java\jdk1.6.0_07\bin\java.exe ^ -classpath ^ lib;^ C:\dev\tools\java\jdk1.6.0_07\lib\tools.jar;^ lib\pde.jar;^ lib\core.jar;^ lib\jna.jar;^ lib\ecj.jar;^ lib\antlr.jar ^ processing.app.Base
- The ^ is the Windows continuation character.
- The java 6 lives in C:\dev\tools\java\jdk1.6.0_07 on my system.
- Any additional jars in C:\dev\tools\processing-1.0.3-expert-Wrj4P5 should be added explicitly, like lib/some-lib.jar;