Error while running Processing with Maven

I’m trying to run an app build with maven with processing-core dependency. As far as I can tell there is problem with one of the internal dependencies in library’s POM file that prevents program from recognizing processing/core/PApplet. Is there anything that can be done to solve this?

Here is my pom.xml file

<xml version="1.0" encoding="UTF-8"?>

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <version>1.0</version>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>14</maven.compiler.source>
    <maven.compiler.target>14</maven.compiler.target>
  </properties>

  <dependencies>
    <!-- https://mvnrepository.com/artifact/org.processing/core -->
    <dependency>
      <groupId>org.processing</groupId>
      <artifactId>core</artifactId>
      <version>3.3.7</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Here is my main class:

package com.mycompany.app;

import processing.core.PApplet;

public class App extends PApplet {
    public static void main( String[] args ) {
        PApplet.main(App.class, args);
        System.out.println( "Hello World!" );
    }
}

My setup:

$ mvn -version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 14.0.2, vendor: Private Build, runtime: /usr/lib/jvm/java-14-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.8.0-33-generic", arch: "amd64", family: "unix"

Relevant error after running mvn package -X

[WARNING] The POM for org.processing:core:jar:3.3.7 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for org.processing:core:3.3.7
[ERROR] 'dependencies.dependency.systemPath' for com.apple:AppleJavaExtensions:jar must specify an absolute path but is ${project.basedir}/apple.jar @ 

Error after running $ java -cp target/my-app-1.0.jar com.mycompany.app.App

Error: Could not find or load main class com.mycompany.app.App
Caused by: java.lang.NoClassDefFoundError: processing/core/PApplet

I’ve tried different available versions at Maven repository

There are two types of dependency to consider, compile time and runtime. You need both how you provide them is up to you, normally it is easier just to include the runtime jar yourself (and place on classpath) but you could use maven to to download the jar for you. However the maven repository is (unofficial not supported and out of date) probably not what you want.

I will try to make maven use local repository. Thank you.
Also it’s strange that there is no official supported version of procesing core maven repo.

Using Processing 3.x with JDK and/or compiler source 14 is unlikely to work anyway. Anything above 8 is likely to give you issues.

I have a Java 11+ fork of Processing 3.5.3 at https://search.maven.org/search?q=g:org.praxislive.libp5x but it needs a bit of work to use with anything other than LWJGL renderer. More for internal use at the moment, but I intend to tidy up and support other use as soon as I get some time to work on it.

Circling back to this thread.

I’m trying to use Processing with Google API that requires either Maven or Gradle.
@neilcsmith @monkstone According to what you’re saying it’s not possible at the moment?

In the screenshot: an error I’m getting trying to run Processing with Maven

Have a look at libp5x. It might work for you. Some Gradle examples at GitHub - codelerity/libp5x-examples: Examples using libp5x Probably won’t work with JDK 19 unless you upgrade the Gradle version though.

Thanks @neilcsmith
Is there anywhere I can find some installation instructions to how to add it to a Gradle project?

That’s kind of what the example repo is for! :wink:

Check Flocking build.gradle or Esfera build.gradle depending on whether you need OpenGL or not.

Thank you!!! :pray:
I’ll try working with that, hope I won’t run into surprisingly difficult issues

I’m getting an error trying to add these folders to eclipse workspace

I know nothing about how Eclipse integrates with Gradle (I’m a NetBeans guy!). But I would assume it won’t work if you’re still using JDK 19. Thanks Gradle! :person_shrugging: Odd that that says unknown Java home directory though.

Try from the CLI with JDK 17 first and check it’s actually working for you.

Class error involving apple is likely caused by ThinkDifferent.java. I explicitly exclude this file from my Processing core 3 Maven version (since it’s not needed). Include the following in your .pom:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
     </repository>
</repositories>
<dependency>
    <groupId>com.github.micycle1</groupId>
    <artifactId>processing3</artifactId>
    <version>3.5.4</version>
</dependency>

(Better yet, use Processing 4 Core Maven Artifact).

Also, you should set a Java build version in your pom (your project is currently at Java-1.5, the default!):

<plugins>
	<plugin>
		<artifactId>maven-compiler-plugin</artifactId>
		<version>3.8.1</version>
		<configuration>
			<source>1.8</source>
			<target>1.8</target>
		</configuration>
	</plugin>
<plugins>

Thanks @micycle !

I’m trying your method
Two things I’m a bit unsure about:

  1. Where should the main processing file be located, and should it have a specific syntax to start with?
  2. Where should the tag be embedded?

@neilcsmith Thanks!
I got stuck with that method, I’ll get back to it if micycle’s approach won’t work

Where should the main processing file be located, and should it have a specific syntax to start with?

You need a sketch file and a entry point (main() method having PApplet.main()) – they can both be included in the same file, and the file(s) can be located anywhere within your project. The main method I use generally looks like this.

public static void main(String[] args) {
	PApplet.main(MySketch.class);
}

Where should the tag be embedded?

What do you mean by “tag”?

By tags I’m referring to the …

Regardless I’m getting an error:

The plugins section should be included in your pom file.


There’s a few problems in your image.

Your java file (which is actually invalid, having no class definition) in not within a source folder, so its being treated as a text file.

Move and fix the class, then create a new run configuration, that is pointed as that ‘main’ class.

Thank @micycle

I’m getting an error when adding the … to the pom file
When I try to run the POM file I’m getting errors all over.

If I’m removing the … I’m getting less errors in the Java file, but it still doesn’t work :confused: