hamoid/video_export_processing

Does not work in exported Mac application

runemadsen opened this issue · 20 comments

This library works perfectly when building from the IDE, but when I run it from an application, I get:

java.lang.NoClassDefFoundError: com/sun/jna/platform/win32/Wincon
	at logogenerator.generateLogo(logogenerator.java:340)
	at logogenerator.draw(logogenerator.java:266)
	at processing.core.PApplet.handleDraw(PApplet.java:2437)
	at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1557)
	at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.platform.win32.Wincon
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 5 more

I'm using Processing 3.3.6 and it crashes on the following line:

VideoExport videoExport = new VideoExport(this, fullpath, pg);

Any thoughts on this? I'm running Java version 9.0.4.

I can reproduce this. I had not tried exporting the app. Very weird, because it mentions win32 even if you're on Mac and I'm on Linux. I'll take a look.

I asked in the Processing forum. I'm not an expert in Java packaging and related issues. I tried printing some debug info from the library and from the sketch, but there's no output, so I believe java is encountering this issue before starting the program.

I'll search for something like #ifdef for java, to see if I could remove code from the source when running certain platforms.

Ok I found one workaround. Look at the launch script. In my case it's called basic. It's missing both jna.jar and jna-platforrm.jar. I added them manually and then the app can be launched.

Before (for a script called basic):

#!/bin/sh

APPDIR=$(readlink -f "$0")
APPDIR=$(dirname "$APPDIR")
java -Xms64m -Xmx2048m -Djna.nosys=true -Djava.library.path="$APPDIR:$APPDIR/lib" -cp "$APPDIR:$APPDIR/lib/basic.jar:$APPDIR/lib/core.jar:$APPDIR/lib/jogl-all.jar:$APPDIR/lib/gluegen-rt.jar:$APPDIR/lib/jogl-all-natives-linux-amd64.jar:$APPDIR/lib/gluegen-rt-natives-linux-amd64.jar:$APPDIR/lib/VideoExport.jar" basic "$@"

After:

#!/bin/sh

APPDIR=$(readlink -f "$0")
APPDIR=$(dirname "$APPDIR")
java -Xms64m -Xmx2048m -Djna.nosys=true -Djava.library.path="$APPDIR:$APPDIR/lib" -cp "$APPDIR:$APPDIR/lib/basic.jar:$APPDIR/lib/core.jar:$APPDIR/lib/jogl-all.jar:$APPDIR/lib/gluegen-rt.jar:$APPDIR/lib/jogl-all-natives-linux-amd64.jar:$APPDIR/lib/gluegen-rt-natives-linux-amd64.jar:$APPDIR/lib/jna.jar:$APPDIR/lib/jna-platform.jar:$APPDIR/lib/VideoExport.jar" basic "$@"

So I just added :$APPDIR/lib/jna.jar:$APPDIR/lib/jna-platform.jar somewhere in that long line.

UPDATE: I forgot to mention that I threw those two libraries inside the lib folder too. I'll figure out if I can automate this in the library.

Should be fixed now. Please re-open if not :)

Thank you so much for the quick turnaround. Will investigate tonight!

It seems like the library wasn't updated in the Processing library manager. Is that something I can help make happen?

I just manually copied version 2.2 into my libraries folder, and I'm still having the same problem with my exported Mac application. I'm wondering whether I made a mistake or the bug is not fixed. Will poke around for a bit and update this issue.

Hi! :) So I was having exactly the same issue you have on my Linux laptop. I figured out the reason was that the jna.jar and jna-platform.jar were not included and not referenced in the exported app.

In linux, the exported app is a folder that contains a launch script. This script now also includes references those two libraries.

  • Is the error you get still the same?
  • Which version of Processing do you use?
  • Could you somehow open the app and see if those jars are found inside your exported app?
  • Is there some kind of text file inside the Mac app referencing a bunch of jar files?
  • If so, are the two jna jar files referenced?

Thanks again for being so responsive. I checked my Mac app package, and it has a ton of .jar files in its Java folder, but those two are missing. There are two core root files in the app – Pkginfo and Info.plist but they don't list .jar files at all. Hmmmm, I guess it's time for me to actually start learning about Mac app packages. If I copy the JAR's into the Java folder, it works. So Processing seems to not know about these two JAR's. @shiffman, would you know?

You're welcome :)
In the library folder you manually installed, do you see a library folder that contains jna.jar jna-platform.jar VideoExport.jar?
If they are in this folder, I assume those jars should be copied when the application is exported.
Do you see any of those three files in the Mac app package? In Linux these files are part of the exported application:

core.jar
gluegen-rt.jar
gluegen-rt-natives-linux-amd64.jar
interactive.jar
jna.jar
jna-platform.jar
jogl-all.jar
jogl-all-natives-linux-amd64.jar
VideoExport.jar

Hi hamoid and runemadsen.
I've made some tests also in windows 10 and the same problem with the Export Application in Windows 10.
Downloaded new 2.2 version and copied jar files and doesn't work. Any update?

Hi @Mantecoder, I have now access to Win 10 and OS X so I'll try them there see what I discover.

Thanks a lot!
If I may help you testing something just say me.

I tried in Windows 10 and it worked fine for me.

  1. Download Processing
  2. Install Video Export Library from inside Processing
  3. Download ffmpeg binary. I placed the executable in C:/Windows/System32/
  4. Open Video Export Basic Example
  5. Export application for Windows, include Java
  6. Look at lib folder in the exported app: it contains VideoExport.jar, jna.jar, jna-platform.jar
  7. Run application. It asks for ffmpeg.exe. Choose its location
  8. Press q to quit
  9. Watch the mp4 video.

Where does it differ for you @Mantecoder ?

I'll try in OSX next.

@runemadsen I tried on Mac OS 10.12.6 (Sierra) and it worked fine. I downloaded processing 3.3.6, ffmpeg was already installed, I added the Video Export Library, run the Basic example successfully, then I exported that example as an app, and it also run fine by double clicking on the app.

What could be the difference? Could you try with the Basic example too? Is there maybe some unexpected interaction with other parts of your project? Do you use many libraries? Different OS?

Hmm, interesting. Here's my import list:

import processing.svg.*;
import java.util.UUID;
import processing.pdf.*;
import com.hamoid.*;
import javax.swing.*;

I'll give it a try with the basic example, but it's good to know that this is local to my project.

Okay, this completely beats me, but it suddenly started working. I have not changed anything or updated neither Processing or VideoExport. Hmmm....

Would be nice to know why, but at least we know that the passing of time has a positive effect on this one :) I'll close it until it shows up again :)

Deal. Thanks for being so responsive! 👍