I just received an Arduino Yun, I have been writing a Java application on my development system using the Oracle JVM. I would like to port this to the Yun, I've installed the jamvm, it is installed in:
/opt/usr/bin/
I've uploaded my jars onto the Yun, when I try to run it using:
/opt/usr/bin/jamvm -jar DSgateway.jar
I get:
Exception occurred while VM initialising.
java/lang/NoClassDefFoundError: jamvm/java/lang/VMClassLoaderData
I have all the required jars in the same folder as DSgateway.jar, I've looked around for help and documentation and can't find anything...
I'm using putty and ssh to connect to the Yun, created script 'java' containing:
exec /opt/usr/bin/jamvm -Xbootclasspath:/opt/usr/share/jamvm/classes.zip:/opt/usr/share/classpath/glibj.zip $1 $2 $3 $4 $5 $6 $7 $8 $9
I installed jamvm on the microsd card.
classes.zip is in /opt/usr/share/jamvm/
glibj.zip is in /opt/usr/share/classpath/
Also tried launching with:
/opt/usr/bin/jamvm -Dgnu.classpath.boot.library.path=/opt/usr/lib/classpath -Xbootclasspath:/opt/usr/share/jamvm/classes.zip:/opt/usr/share/classpath/glibj.zip -jar DSgateway
.jar
But when I run either the script or the above, I get:
Exception occurred while VM initialising.
java/lang/NoClassDefFoundError: java/lang/Class
Well, you know all my settings now; the only thing I can think of is: did you use an ext2/ext3/ext4 formatted SD disk? (the jamvm installation needs a couple of symbolic links and a FAT16/32 formatted disk can't create symbolic links).
mount:
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=30568k)
tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,noatime,mode=600)
/dev/mtdblock3 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlayfs (rw,noatime,lowerdir=/,upperdir=/overlay)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
/dev/sda1 on /opt type ext4 (rw,noatime)
/dev/sda2 on /mnt/sda2 type ext4 (rw,sync,relatime,data=ordered)
Its looking and sounding like the actual package install was not completed successfully, some folders not present...also looks like my SD card may have some corruption, fixing these now, will probably download jamvm and install manually.
Then reinstalling, 'opkg install jamvm', it would seem that now it will fit, no complaints or error messages, that were displayed initially and I had to install it on microSD.
But now after a supposedly good install, I can't find any sign of glibj.zip
It should be: /opt/usr/share/classpath/glibj.zip; the other one should be: /opt/usr/share/jamvm/classes.zip. Also see the -X option in the 'java' script above.
Been away all week, returned refresh and started over, this time have progressed better, the same application runs fine in standard java environment on PC, but under jamvm I get:
java.lang.ClassNotFoundException: cantley/co/uk/clsMain
at java.lang.VMClass.forName(Native Method)
at java.lang.Class.forName(Class.java:233)
at jamvm.java.lang.JarLauncher.main(JarLauncher.java:46)
I'm not really sure what this is saying because the main class is present in the jar,
Use Rootfs, then install jamvm as standard package, or wait linino team updated Uboot which could release 8 MB mirror image at 16 MB flush memory, as total of 15 MB then installing jamvm is a piece of cake.
That means that you didn't run your classes from a .jar file with your other Java implementation. Jamvm doesn't know which class in the .jar file to use for a starting point. You need to have a manifest entry in your .jar file as follows;
I export the project as a Runnable JAR file, it doesn't give me the option of creating a manifest file.
I did find the manifest in the generated jar file, it contains:
Manifest-Version: 1.0
Rsrc-Class-Path: ./ netty-codec-http-4.0.13.Final.jar slf4j-api-1.7.5.
jar jackson-databind-2.2.3.jar RXTXcomm.jar slf4j-simple-1.7.7.jar ja
ckson-core-2.2.3.jar netty-socketio-1.6.0.jar jackson-annotations-2.2
.3.jar netty-common-4.0.13.Final.jar netty-buffer-4.0.13.Final.jar ne
tty-codec-4.0.13.Final.jar netty-handler-4.0.13.Final.jar netty-trans
port-4.0.13.Final.jar
Class-Path: .
Rsrc-Main-Class: cantley.co.uk.clsMain
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
Looks like the Main-Class isn't correct. I've edited and changed to read:
Main-Class: cantley.co.uk.clsMain
Now I get:
java.lang.reflect.InvocationTargetException
at java.lang.reflect.VMMethod.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:327)
at jamvm.java.lang.JarLauncher.main(JarLauncher.java:50)
Caused by: java.lang.OutOfMemoryError
<>
I then modified the build to export the files to a sub-folder, the manifest now reads:
java.lang.ClassNotFoundException: cantley/co/uk/clsMain
at java.lang.VMClass.forName(Native Method)
at java.lang.Class.forName(Class.java:233)
at jamvm.java.lang.JarLauncher.main(JarLauncher.java:46)