caprica / picam

Unofficial Java API library for the Raspberry Pi camera.
GNU General Public License v3.0
49 stars 11 forks source link

PicamNativeLibrary installLibrary throw exception at FileSystems creation #17

Closed AlexanderBykin closed 5 years ago

AlexanderBykin commented 5 years ago
Environment:
 java.home           : /opt/ejdk1.8.0_191
 java.version        : 1.8.0_191
 java.runtime.name   : Java(TM) SE Embedded Runtime Environment
 java.runtime.version: 1.8.0_191-b12
 java.vm.info        : mixed mode
 java.vm.name        : Java HotSpot(TM) Embedded Client VM
 java.vm.version     : 25.191-b12
 os.version          : 4.14.79-v7+
 /etc/issue          : Raspbian GNU/Linux 9 \n \l

When run libary test sudo java -jar ./picam-2.0.3-SNAPSHOT.jar 1280 800 test.jpg i see error bellow

java.nio.file.ProviderNotFoundException: Provider "jar" not found
        at java.nio.file.FileSystems.newFileSystem(Unknown Source)
        at java.nio.file.FileSystems.newFileSystem(Unknown Source)
        at uk.co.caprica.picam.PicamNativeLibrary.installLibrary(PicamNativeLibr
ary.java:168)
        at uk.co.caprica.picam.PicamNativeLibrary.installTempLibrary(PicamNative
Library.java:83)

As we can see this error related to FileSystems and method newFileSystem, not native library error.

But when we run test (.so library is just copied from sources) sudo java -Dpicam-native=/tmp/picam-2.0.1.so -jar ./picam-2.0.3-SNAPSHOT.jar 1280 800 test.jpg i see that test working fine and picture was taken!

tested with version 2.0.2 from Maven repo and 2.0.3 self compiled

As a note: As you can see i run at Java SE Embedded Virtual Machine created with tool from Oracle(link ARM v6/v7 Linux - VFP, HardFP ABI, Little Endian) used command

./ejdk1.8.0_191/bin/jrecreate.sh \
    --dest /tmp/ejdk1.8.0_191 \
    --profile compact3 \
    --vm client \
    --extension locales
caprica commented 5 years ago

So... if you specify -Dpicam-native then it does not try and extract the temporary library from the jar file, so that would be expected to work.

As to why the jar provider can't be found... are you using JDK modules? If so you may need to explicitly require the module that provides the jar/zip filesystem.

AlexanderBykin commented 5 years ago

are you using JDK modules? i don't think so, because it is JRE version i need to dig that info related to JRE Embedded and FileSystemProvider for jar schema also one thing i see, when i define -Dpicam-native variable and program finished .so library was deleted, can it be keeped?

caprica commented 5 years ago

Please check carefully if you are using JDK modules or not (or if you need to) because I really suspect that the required filesystem module is missing when you create your custom JDK bundle.

Regarding keeping the shared object, yes, it can be kept. Please have a look at the PicamNativeLibrary class Javadoc for methods that you can use to extract and keep the file (but it will require you to have working jar filesystem provider to extract the library in the first place).

On the other hand, if you want to use the -Dpicam-native property you can copy the shared object wherever you want and control whether it's deleted or not yourself.

AlexanderBykin commented 5 years ago

@caprica i found solution, thanks for suggestion, i think this explanation should be placed at Readme. JVM should be server related, changed Java Embedded build script

./ejdk1.8.0_191/bin/jrecreate.sh \
    --dest /tmp/ejdk1.8.0_191 \
    --vm server \
    --extension locales

Builded VM, copied to Raspberry and run test again with command sudo java -jar ./picam-2.0.3-SNAPSHOT.jar 1280 800 test.jpg Got it working fine!

caprica commented 5 years ago

What are the benefits of using the embedded JDK rather than the Oracle JDK?

AlexanderBykin commented 5 years ago

benefits: