My goal: Running Processing.org (version 3.5.4) from Max (cycling74) version 8 on Windows 10 64 through writing an MXJ external (Max Java support). I want to open a processing test sketch within window from MAX by sending a bang message to the MXJ external. For this I have
class MaxJavaTest3 extends MaxObject which calls
class TestProcessing extends PApplet.
public class MaxJavaTest3 extends MaxObject {
public void bang() {
String[] args = {};
TestProcessing.main(args);
}
}
public class TestProcessing extends PApplet {
public static void main(String args[] ) {
PApplet.main("TestProcessing", args);
}
public void settings() {
size(920, 780);
}
public void setup() {
background(0);
fill(255, 0, 0);
circle(width/2, height/2, 80);
}
}
In IntelliJ, I set the dependencies for Max and Java. The bang message is received in Java e.g. triggering some text messages to the console. If I execute PApplet.main via the entry point TestProcessing.main, the processing window opens. So far so good, but trying to invoke PApplet.main via MaxJavaTest3.bang() method I get the error:
java.lang.RuntimeException: java.lang.ClassNotFoundException: TestProcessing
at processing.core.PApplet.runSketch(PApplet.java:10852)
at processing.core.PApplet.main(PApplet.java:10657)
at TestProcessing.main(TestProcessing.java:11)
at MaxJavaTest3.bang(MaxJavaTest3.java:19)
Caused by: java.lang.ClassNotFoundException: TestProcessing
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at processing.core.PApplet.runSketch(PApplet.java:10845)
... 3 more
```JAVA
I found a post which suggests that there is a problem with Max using ProcessingĀ“s OpenGL related capacities: "since OpenGL uses also native libraries (*.dll files) and not only *.jar files. I don't know if its possible in MaxMSP - that depends on how they set up their JVM."
https://forum.processing.org/one/topic/use-processing-from-within-max-msp-or-from-matlab.html
Related
I have only worked with Processing's standard renderer until now. I got a java project where i am working with processing included via maven.
Since other renderers might be faster, i wanted to try using another for my current project, but any other renderer fails for me (P2D, P3D, FX2D). Only the default, Java2D works.
Seemed weird to me, so i started another project with nothing in it, just creating an empty frame. I first tried running it in the Processing.exe as a sketch, and it worked:
The Sketch code:
void setup()
{
size(500, 200, P3D);
}
void draw()
{
}
I then rewrote it into plain java:
import processing.core.PApplet;
public class Test extends PApplet
{
public void setup() {
}
public void draw() {
}
public void settings() {
this.size(500, 200, P3D);
}
public static void main(final String[] passedArgs) {
final String[] appletArgs = { "Test" };
if (passedArgs != null) {
PApplet.main(concat(appletArgs, passedArgs));
}
else {
PApplet.main(appletArgs);
}
}
}
No matter what i tried so far, i keep running into the following exeption:
java.lang.NoClassDefFoundError: com/jogamp/opengl/GLException
at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:712)
at processing.opengl.PGraphicsOpenGL.<init>(PGraphicsOpenGL.java:569)
at processing.opengl.PGraphics3D.<init>(PGraphics3D.java:35)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at processing.core.PApplet.makeGraphics(PApplet.java:2235)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2314)
at processing.core.PApplet.initSurface(PApplet.java:10828)
at processing.core.PApplet.runSketch(PApplet.java:10767)
at processing.core.PApplet.main(PApplet.java:10467)
at Test.main(Test.java:19)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 14 more
java.lang.RuntimeException: com/jogamp/opengl/GLException
at processing.core.PApplet.makeGraphics(PApplet.java:2268)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2314)
at processing.core.PApplet.initSurface(PApplet.java:10828)
at processing.core.PApplet.runSketch(PApplet.java:10767)
at processing.core.PApplet.main(PApplet.java:10467)
at Test.main(Test.java:19)
I am working with Java 17, and already tried to run with Java 8 as i read this might work, but.. it didnt.
Is it not possible to run those P2D, P3D, FX2D sketches outside of the processing.exe?
An even better solution to this problem would be to just use the newer processing4.
Micycle1 made the processing4-core usable with maven via JitPack: https://github.com/micycle1/processing-core-4
Adding following dependencies to the pom.xml solved it:
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt-main</artifactId>
<version>2.3.2</version>
</dependency>
I am getting an error when running java program using processing core v 3.3.7.
I tried other versions, but it didn't help.
The error I get is the following:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 2
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:3319)
at java.base/java.lang.String.substring(String.java:1874)
at processing.core.PApplet.<clinit>(PApplet.java:120)
The code is provided below:
import processing.core.PApplet;
public class ProcessingTest extends PApplet {
#Override
public void settings() {
size(200, 200);
}
#Override
public void draw() {
background(0);
fill(255, 0, 0);
ellipse(100, 100, 100, 100);
}
public static void main (String... args) {
ProcessingTest pt = new ProcessingTest();
PApplet.runSketch(new String[]{"ProcessingTest"}, pt);
}
}
I can't see what the problem is.
Strangely enough I couldn't replicate your issue.
Is your class in a package ? If so, might be worth passing the full class path including the package. e.g:
PApplet.runSketch(new String[]{ProcessingTest.class.getCanonicalName()}, pt);
you can also try:
PApplet.main(ProcessingTest.class.getCanonicalName());
Additionally, it's worth mentioning what OSX you're on and what JDK you used to compile, and what your machine outputs when calling System.getProperty("java.version");.
Having a quick skim through Processing source code I spotted this line:
javaPlatform = parseInt(version.substring(0, version.indexOf('.')));
Depending on your OS this might a basic bug parsing an unexpected string.
When I attempt to create a new anonymous Action subclass inside the initialization of an anonymous subclass of its containing class's containing class, Netbeans suddenly fails to find the main class when running, despite being able to clean+build with no problem and to run with this code commented out.
Code structure:
Main package:
Main class <-- currently looking at this file
public void run(...) (called in main(String[] args))
Actor a = new Actor() {
Script script = new Script();
{ (Actor instance initiation code)
script.new Action(0) {...} causes breakage
Package actor
public abstract class Actor
public class Script
public abstract class Action
Replicated in a simple class:
package tests;
public class ClassTester {
public static void main(String[] args) {
ClassTester tester = new ClassTester();
tester.run();
}
public void run() {
final Inner1 A = new Inner1() {
{
B = this.new Inner2() {
#Override
public void run() {
System.out.println("Hello, world!");
}
};
}
};
A.B.run();
}
public class Inner1 {
public Inner2 B;
public abstract class Inner2 implements Runnable {
}
}
}
-->
Error: Could not find or load main class tests.ClassTester
Java Result: 1
Interestingly, -XX:+PrintCompilation reveals that something runs before the crash:
50 1 java.lang.String::hashCode (55 bytes)
50 2 java.lang.String::charAt (29 bytes)
Error: Could not find or load main class tests.ClassTester
Java Result: 1
Product Version: NetBeans IDE 7.3.1 (Build 201306052037)
Java: 1.7.0_25; Java HotSpot(TM) 64-Bit Server VM 23.25-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_25-b17
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Cleaning and building and restarting Netbeans have not resolved the problem. Is this fixable or a bug in Netbeans?
I was able to reproduce the issue in NetBeans 7.3.1. The problem appears to be related to bug #224770. The fix summary is #224770: making handling of new with enclosing expression more similar to vanilla javac, while preserving the correct outputs from the API.
You have two options.
Upgrade NetBeans to 7.4 or newer. I tested the code in 7.4 and it worked properly.
Keep using NetBeans 7.3, and don't use "this.new". Change line 11 to this:
B = new Inner2() {
I have been trying to export a standalone application for Mac using the "Export Application" function in Processing. The simple application, which involves updating a float value on the screen that corresponds to the y-axis position of a hand detected by a Leap Motion, works perfectly well within Processing. However, once I export the application and try to run it, the app opens for a brief second and quickly closes. I have exported applications from Processing successfully before, but not one that uses the Leap SDK. I am using the LeapMotion library for Processing to access the Leap SDK: https://github.com/heuermh/leap-motion-processing. Here is my code:
import processing.core.*;
import com.leapmotion.leap.processing.*;
import com.leapmotion.leap.Controller;
import com.leapmotion.leap.Listener;
public class Test extends PApplet {
Controller controller;
MyListener listener;
float position = 0.0f;
class MyListener extends Listener {
public void onFrame(Controller controller) {
if (!controller.frame().hands().isEmpty()) {
position = controller.frame().hands().leftmost().palmPosition().get(1);
}
}
}
public void setup() {
size(600,600);
controller = new Controller();
listener = new MyListener();
controller.addListener(listener);
}
public void draw() {
background(0);
textAlign(CENTER,CENTER);
textSize(50);
text(position, 300,300);
}
public static void main(String args[]) {
PApplet.main("Test");
}
}
When I export the application, the contents of the application are as follows:
Info.plist
Java
-core.jar
-gluegen-rt-natives-macosx-universal.jar
-gluegen-rt.jar
-jogl-all-natives-macosx-universal.jar
-jogl-all.jar
-LeapJava.jar
-LeapMotion.jar
-libLeap.dylib
-libLeapJava.dylib
-Test.jar
MacOS
-Test
Plugins
-jdk1.7.0_45.jdk
Resources
-en.lproj
-sketch.icns
PkgInfo
Any help would be greatly appreciated!
P.S. I've already tried bundling the program into a runnable JAR file.
I have a following problem with an innner class. Here's the code:
public class PGZUserManagerBean {
// joomla login as separate thread
private class JoomlaLogin extends Thread {
private AuthJoomla authJoomla;
public JoomlaLogin(AuthJoomla authJoomla){
this.authJoomla = authJoomla;
}
#Override
public void run(){
this.authJoomla.authJoomla();
}
}
public void validateuser(){
AuthJoomla authJoomla = new AuthJoomla();
JoomlaLogin joomlaLogin = new JoomlaLogin(authJoomla);
joomlaLogin.start();
}
}
I'm getting java.lang.ClassNotFoundException: PGZUserManagerBean$JoomlaLogin on runtime. I'm using Java 1.6.
Thank you for the help in advance.
al
I strongly suspect that you've copied the class files from one place to another (or put them in a jar file) but you've failed to copy/include PGZUserManagerBean$JoomlaLogin.class.
Check where you're running the code, and look for the class file that the JVM can't find. It will definitely be in your compilation output.