Run gstreamer-java PlayBinVideoPlayer example on command line

320 views
Skip to first unread message

František Kadúch

unread,
Mar 3, 2019, 5:00:05 PM3/3/19
to gstreamer-java
Hi all,
I succesfully build in Netbeans IDE 8.2 gst1-java-core (latest commit  a6ab456) and gst1-java-examples (latest commit  107a6d4). I can also run it from Netbeans selecting as a main class  org.freedesktop.gstreamer.examples.PlayBinVideoPlayer and it works fine.
However, when I try to launch on the command line, I get this error:

c:\Projects\Netbeans\gst1-java-examples-master\target>java -jar gst1-java-examples-1.0.0-SNAPSHOT.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/freedesktop/gstreamer/Bus$MESSAGE
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.freedesktop.gstreamer.Bus$MESSAGE
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 7 more

Could  you please indicate me how to fix this error? Any help with the topic how to run gst1-java-example examples from command ine is highly appreciated,
it could be added afterwards to documentation, on how to run examples from CLI.
My environment:
Windows 8.1
Netbeans 8.2
gst1-java-core
gst1-java-example

Many thanks
pom.xml

Neil C Smith

unread,
Mar 4, 2019, 6:32:26 AM3/4/19
to gstream...@googlegroups.com
Hi,

On Sun, 3 Mar 2019 at 22:00, František Kadúch
<frantise...@gmail.com> wrote:
> c:\Projects\Netbeans\gst1-java-examples-master\target>java -jar gst1-java-examples-1.0.0-SNAPSHOT.jar
> Error: A JNI error has occurred, please check your installation and try again

Which version of the JDK are you using? A quick Google would suggest
that error message is actually a rather unhelpful message caused by
missing libraries on the classpath, which that stack trace and launch
command would otherwise suggest.

The examples repo is exactly that - it is code to be adapted for your
own projects. it is not set up to be built and run as a standalone
project in that way as no main class is specified, and you're missing
references to gst1-java-core and JNA. You need to package this up as
you would with any other Java application with third-party
dependencies.

You could run this from the CLI in various ways - eg. on my Linux box
I can run it from inside the Maven directory where the JAR is built by
specifying the classpath and main class manually -

java -cp gst1-java-examples-1.0.0-SNAPSHOT.jar:../../gst1-java-core/1.0.0-beta-1/gst1-java-core-1.0.0-beta-1.jar:../../../../../net/java/dev/jna/jna/5.2.0/jna-5.2.0.jar
org.freedesktop.gstreamer.examples.PlayBinVideoPlayer

This is not the ideal way to use the examples! ;-)

Best wishes,

Neil

--
Neil C Smith
Artist & Technologist
www.neilcsmith.net

PraxisLIVE - hybrid visual live programming
for creatives, for programmers, for students, for tinkerers
www.praxislive.org

František Kadúch

unread,
Mar 4, 2019, 4:58:19 PM3/4/19
to gstreamer-java
Hi Neil,

thanks for your reply, I use jdk1.8.0_172 installed in :
C:\Program Files\Java\jdk1.8.0_172

However, when I run example jar from CLI like this:

c:\Projects\Netbeans\gst1-java-examples-master\target>java -cp gst1-java-examples-1.0.0-SNAPSHOT.jar:..\..\gst
1-java-core-master\target\gst1-java-core-1.0.0-SNAPSHOT.jar:..\..\..\..\c:\Downloads\Software\Java\jna-4.5.1.jar org.freedesktop.gstreamer.examples.PlayBinVideoPlayer

I get this error message:
Error: Could not find or load main class org.freedesktop.gstreamer.examples.PlayBinVideoPlayer

Could you please take a look at this?
thanks

Frantisek

Neil C Smith

unread,
Mar 5, 2019, 4:55:34 AM3/5/19
to gstream...@googlegroups.com
On Mon, 4 Mar 2019 at 21:58, František Kadúch
<frantise...@gmail.com> wrote:
> Could you please take a look at this?
>
> On Monday, 4 March 2019 12:32:26 UTC+1, Neil C Smith wrote:
>> This is not the ideal way to use the examples! ;-)

^^ I meant that!

If you insist on doing this, please review the Java launcher command
documentation as your classpath definition looks incorrect. Also, use
1.0.0-beta-1 with the examples, and make sure you're using JNA 5.2+

Why exactly are you trying to run the examples on the CLI like this?
What are you trying to achieve?

František Kadúch

unread,
Mar 5, 2019, 5:16:44 AM3/5/19
to gstream...@googlegroups.com
Well , I need to launch gstreamer from Java app, it outside of t the IDE , of course So it's the same like launch from Java app with exec command. It's an interactive TV app, which consumes HLS streams from our Wowza streaming server, later on will use also DRM. Actually, it's the same issue I am trying to solve with my son Filip Kaduch, who also posted a question here. 
BTW, Java classpath is correct, I need to probably embed main class info in the manifest file.

thanks

ut 5. 3. 2019 o 10:55 Neil C Smith <ne...@neilcsmith.net> napísal(a):
--
You received this message because you are subscribed to the Google Groups "gstreamer-java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gstreamer-jav...@googlegroups.com.
To post to this group, send email to gstream...@googlegroups.com.
Visit this group at https://groups.google.com/group/gstreamer-java.
For more options, visit https://groups.google.com/d/optout.

Neil C Smith

unread,
Mar 5, 2019, 5:41:35 AM3/5/19
to gstream...@googlegroups.com
On Tue, 5 Mar 2019 at 10:16, František Kadúch
<frantise...@gmail.com> wrote:
> Well , I need to launch gstreamer from Java app, it outside of t the IDE , of course So it's the same like launch from Java app with exec command.

I understand that part! But running the Maven artefacts, or the
example jar at all, like that is not the way to achieve it. Just
build and bundle an application from scratch, copying in and adapting
whichever example you want to make use of, and adding in the
dependencies.

> BTW, Java classpath is correct, I need to probably embed main class info in the manifest file.

At least the use of colon vs semicolon and the relative directory
traversal in front of the (wrong) JNA dependency are suspicious! You
don't need the main class in the manifest with this approach.

If you really want to use the raw java launch command, rather than one
of various better distribution options, then at least make a project
that puts the jars in one place. Doing that you could create even add
a main class and the dependencies to the jar manifest
(https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#classpath)
if you're insistent on using the java launcher directly via -jar.

The examples repository will not be adapted to work in this way.

František Kadúch

unread,
Mar 5, 2019, 5:12:16 PM3/5/19
to gstreamer-java
Hi Neil,

I finally managed to lauch PlayBinVideoPlayer example from the CLI ! 
I am using this command :

c:\Projects\Netbeans\gst1-java-examples-master\target>java -cp gst1-java-examples-1.0.0-SNAPSHOT.jar;..\..\gst
1-java-core-master\target\gst1-java-core-1.0.0-SNAPSHOT.jar;..\..\..\..\Downloads\Software\Java\jna-4.5.1.jar;
c:\Projects\Netbeans\gst1-java-examples-master\target\classes\ org.freedesktop.gstreamer.examples.PlayBinVideo
Player
'C:\gstreamer\1.0\x86_64\lib\gio\modules\libgiognutls.dll': Zadanř modul sa nepodarilo nßjsŁ.
Failed to load module: C:\gstreamer\1.0\x86_64\lib\gio\modules\libgiognutls.dll

You were right that I had a mistake with colon instead of semicolon in my classpath option, otherwise it was ok.
There is still a minor error with libgiognutls.dll which the loader cannot find, although it is located in lib\gio\modules directory. Could you please help me with this error, too?

great thanks

Neil C Smith

unread,
Mar 5, 2019, 5:18:24 PM3/5/19
to gstream...@googlegroups.com


On Tue, 5 Mar 2019, 22:12 František Kadúch, <frantise...@gmail.com> wrote:
There is still a minor error with libgiognutls.dll which the loader cannot find, although it is located in lib\gio\modules directory. Could you please help me with this error, too?

Try looking back through the mailing list archive around setting up Windows path. 

Best wishes, 

Neil

Sadeeb Ahsan

unread,
Dec 19, 2019, 12:59:28 PM12/19/19
to gstreamer-java
Hi František, i have been trying to build gst1-java-core in Netbeans 8.2. Could you please briefly describe the procedure. The readme file in the github repository seems unclear. 

Neil C Smith

unread,
Dec 19, 2019, 1:06:33 PM12/19/19
to gstream...@googlegroups.com
On Thu, 19 Dec 2019 at 17:59, Sadeeb Ahsan <sadee...@gmail.com> wrote:
>
> Hi František, i have been trying to build gst1-java-core in Netbeans 8.2. Could you please briefly describe the procedure. The readme file in the github repository seems unclear.

Building or running? Building should just be like any other Maven
project in NetBeans. What OS are you using? Make sure you have the
native GStreamer library installed, and make sure you've set up the
system path correctly to find it.

What's wrong with NetBeans 11.2?! ;-)

Best wishes,

Neil

--
Neil C Smith
Codelerity Ltd.
www.codelerity.com

Codelerity Ltd. is a company registered in England and Wales
Registered company number : 12063669
Registered office address : Office 4 219 Kensington High Street,
Kensington, London, England, W8 6BD
Reply all
Reply to author
Forward
0 new messages