Run a Papart App from Processing (Netbeans)


#1

Run in pure Java

Processing is great for prototyping, however for larger projects you need structure. This structure can be achieved using pure Java. In this tutorial, we show how to:

  • Compile Processing applications in Java using maven.
  • Compile and Run PapARt applications in Java with maven.

Requirements

Here you list the hardware / OS required: e.g.:

  • Hardware: any.
  • Operating system: Win/OSX/Linux.
  • Language: Java
  • Time required: 30mins.
  • Difficulty: easy.

Folder organization.

Processing: all libraries.

From the Processing wiki:How to Install a Contributed Library:

     Documents   
           Processing ## what sketchbook on linux
                 your sketch folders
                 libraries
                       theLibrary
                             examples
                             library
                                   theLibrary.jar
                             reference
                             src

PapARt library

The library stores the jar files that contains the code. In the library, we usually ship the source code, and the javadoc and more importantly all the calibration/configuration files.

     Documents   
           Processing ## what sketchbook on linux            
                 libraries
                       PapARt
                             data
                                  calibration  ## cameras, projectors, tracking configs etc...
                                  markers      ## files for tracking and printing.
                             library
                                   PapARt.jar  ## (symlinks are supported)
                                   pca_transform.jar, jama.jar   ## other external jar files.
                             apidocs           ## javadoc
                             src

How PapARt finds its data.

When a PapARt application starts, it tries to find the `Processing` 
folder, then the `PapARt` library. This happens when lauched, from
Processing, or from maven. 

Seach process:

  1. The SKETCHBOOK environment variable. You can set it by adding in your ~/.profile file: export SKETCHBOOK=$HOME/sketchbook in linux. It works the same in Windows, or OSX.
  2. If there is no SKETCHBOOK environment variable, it tries to find the HOME variable, then on Windows and OSX the folder $HOME/Processing/libraries/PapARt/data/, and in Linux $HOME/sketchbook/libraries/PapARt/data/.
  3. (Worst case) If this also fails, it tries to find a file relative to the jar that contains Papart.class : ../data/.

In every case you will get feedback in the console :

Papart data path:  ....
## or an error: 
Error in loading the Sketchbook folder. 
Papart: Cannot find the data folder. It must be installed with the library.

Conclusion

PapARt is designed as a Processing libray and requires to be installed like so. This may become optional, or more configurable in the next release.


#2

My Papart data path currently is correct, I can check with linux command echo $SKETCHBOOK.

But I have a concern here, like you said that:

Because we have dependencies from pom.xml when launched with maven. It will get library from PapARt library from Processing folder first or from dependencies first like following:

<dependency>
        <groupId>fr.inria</groupId>
        <artifactId>papart</artifactId>
        <version>1.2-SNAPSHOT</version>
    </dependency>

Currently, the version of PapARt library in Processing folder is 1.4.0 but in the pom.xml is 1.2-SNAPSHOT (https://forge.pole-aquinetic.net/RealityTech/Papart-exemples/blob/1.4-rc/java/exampleDeploy/pom.xml ) get from http://repository.rea.lity.tech/fr/inria/papart/ . Could you show me the way to get libraries directly from libraries in Processing folder in maven, because repositories seem out-updated for referenced libraries?

P/S: 2 java examples from https://forge.pole-aquinetic.net/RealityTech/Papart-exemples/tree/1.4-rc doesn’t work with PapARt ver 1.4-rc.


#3

Hello Hung,

The only java example is named “example” is the java folder. The other two: exampleDeploy, and exampleDeployNetbeans are created to run PapARt application on another machine.

You have to update to 1.4-SNAPSHOT, and compile PapARt before. You can access it on the forge: PapARt-1.4-rc.

<dependency>
        <groupId>fr.inria</groupId>
        <artifactId>papart</artifactId>
        <version>1.4-SNAPSHOT</version>
    </dependency>

#4

Thanks Jeremy,

It’s working after I’ve modified the version of papart to 1.4- SNAPSHOT like you said and added some missing dependencies like following:

    <dependency>
        <groupId>org.clojars.hozumi</groupId>
        <artifactId>toxiclibscore</artifactId>
        <version>0022</version>
    </dependency>
    
    <dependency>
        <groupId>tech.lity.rea</groupId>
        <artifactId>SVGExtended</artifactId>
        <version>3.3.6.1</version>
    </dependency>

However, I got an other small issue. How we can configure this app for running on specific screen with the maven command mvn exec:java -Dexec.mainClass="tech.lity.rea.example.SeeThrough", it always runs on main screen. I need it runs on the screen of projection.

With processing IDE, we can select screen on File>Reference> Run Sketches on display. Do we have a similar when run with maven?


#5

Yes, you can set the display to use from the fullscreen method:

void settings(){
  fullScreen(P3D, 2);  // 2 is display number.
}