Pandora Programming Java For The Pandora


Sploshi

Still Fresh
Joined
Jul 2, 2010
Messages
44
I've just started learning to program in Java and I was just wondering (because I can't find this anywhere else - although maybe I've just not looked hard enough):

Once I have my final java project, how to I make it into a compatible ".pnd" file?
 
Josh Yaxley said:
I've just started learning to program in Java and I was just wondering (because I can't find this anywhere else - although maybe I've just not looked hard enough):

Once I have my final java project, how to I make it into a compatible ".pnd" file?
You have to bundle a JVM along with your PND, as the Pandora doesn't have one at the moment.

OR you can do it like this (I don't have a Pandora so I haven't actually tested it):
Code:
#!/bin/bash
# Checks for a JVM and installs it if it's missing,
jar='./bin/myjar.jar' #Insert the name of your JAR file here

if [ ! -x '/usr/bin/java' ]; then
  gksudo ./bin/installjava.sh
fi

java -jar "$jar" $@
...and in a file 'bin/installjava.sh':
Code:
#!/bin/bash
# Installs a JVM on the Pandora
xterm -e 'opkg update'
xterm -e 'okpg install jamvm'
 
Last edited by a moderator:
Oh and I probably should've mentioned I use Mac OS X.

Would this make your answer any different?

EDIT: Oh wait, were those commands to be executed on the Pandora?
 
Josh Yaxley said:
Oh and I probably should've mentioned I use Mac OS X.

Would this make your answer any different?

EDIT: Oh wait, were those commands to be executed on the Pandora?
Yes, they're for the launch script in the pnd so your app can auto install java. You'd want to inform people who download your app that it installs java though, so it doesn't install things without their permission.
 
Last edited by a moderator:
Josh Yaxley said:
Oh and I probably should've mentioned I use Mac OS X.

Would this make your answer any different?

EDIT: Oh wait, were those commands to be executed on the Pandora?
Well you don't have to do anything differently on your development machine.

I bet you're thinking that you'll have to use something like the Android SDK or compile your app for Dalvik, but you don't. You just create your Java application like you're used to, and compile it to an executable .jar file, exactly like you would for Windows/Linux/Mac etc. and you're good to go.

The problem I'm addressing above is that Java isn't installed on the Pandora, so to let the user of your application have a seamless experience, you'll have to write a script that first installs Java and then starts your JAR file. That's what the code above does.
 
Last edited by a moderator:
Ah okay I understand now.

So would that code be in a readme telling the user to input it into the command line terminal?
 
how would be the java Performance onto the Pandora? I just asking because "Minecraft" would be very funny to play onto the Pandora:
www.minecraft.net

But this "nearly 0 graphics" game runs with Java and the VM already eats over 50% of CPU Power and I have a 2.66GHz Quad-Core PC!
 
Josh Yaxley said:
Ah okay I understand now.

So would that code be in a readme telling the user to input it into the command line terminal?
Either that, or you'd just put it in a script file as I suggested. So instead of double clicking on the JAR file, the user would double click on the script, and the script would check for a Java installation and then launch the JAR. This makes it possible to put the application in a PND file, as well.

fusion_power said:
how would be the java Performance onto the Pandora? I just asking because "Minecraft" would be very funny to play onto the Pandora:
www.minecraft.net

But this "nearly 0 graphics" game runs with Java and the VM already eats over 50% of CPU Power and I have a 2.66GHz Quad-Core PC!
That game uses LWJGL, which is an old library, kind of like SDL, for Java. Its... well old, slow and buggy, and won't work on the Pandora because it doesn't support OpenGL 2.0 (LWJGL requires OpenGL 2.0 or OpenGL 1.1)
 
Last edited by a moderator:
Personal opinion:
I think no PND should be installing packages on the NAND unless it is specifically the purpose of the PND.
Either inform the users what they need to have installed in a readme or have two separate PND, one specifically for setting up Java and another with your program.

but that's just me.
 
dflemstr said:
That game uses LWJGL, which is an old library, kind of like SDL, for Java. Its... well old, slow and buggy, and won't work on the Pandora because it doesn't support OpenGL 2.0 (LWJGL requires OpenGL 2.0 or OpenGL 1.1)
Then I even wondering more, why this sureley talented coder choosed Java instead of a fast, modern alternative. Maybe it is because of the WEB interface/browser or because one and the same game runs onto Win/Linux/Mac, I don't know. Well, at least I can run it onto my PC pretty well. ^^
 
Last edited by a moderator:
fusion_power said:
dflemstr said:
That game uses LWJGL, which is an old library, kind of like SDL, for Java. Its... well old, slow and buggy, and won't work on the Pandora because it doesn't support OpenGL 2.0 (LWJGL requires OpenGL 2.0 or OpenGL 1.1)
Then I even wondering more, why this sureley talented coder choosed Java instead of a fast, modern alternative. Maybe it is because of the WEB interface/browser or because one and the same game runs onto Win/Linux/Mac, I don't know. Well, at least I can run it onto my PC pretty well. ^^
It's not Java that is the problem, it's LWJGL. It's perfectly fine to write games in Java, but not in LWJGL.
 
Last edited by a moderator:
dflemstr said:
Josh Yaxley said:
I've just started learning to program in Java and I was just wondering (because I can't find this anywhere else - although maybe I've just not looked hard enough):

Once I have my final java project, how to I make it into a compatible ".pnd" file?
You have to bundle a JVM along with your PND, as the Pandora doesn't have one at the moment.

OR you can do it like this (I don't have a Pandora so I haven't actually tested it):
Code:
#!/bin/bash
# Checks for a JVM and installs it if it's missing,
jar='./bin/myjar.jar' #Insert the name of your JAR file here

if [ ! -x '/usr/bin/java' ]; then
  gksudo ./bin/installjava.sh
fi

java -jar "$jar" $@
...and in a file 'bin/installjava.sh':
Code:
#!/bin/bash
# Installs a JVM on the Pandora
xterm -e 'opkg update'
xterm -e 'okpg install jamvm'

I don't want people to install things from the repo without my permission on my Pandora. :\ It should be included in the PND until we can convince ED to add it to the firmware image.

-God Ginrai
 
Last edited by a moderator:
Yeah, a seperate "Install Java.pnd" seems to be the best option then (and a "readme.txt" explaining that the user needs to install it and then of course the "game.jar" :))

Although it would be much simpler if it was included in the firmware - is there a reason it isn't?
 
I imagine the reason its not included is due to considerations about the space of the default factory image .. My personal opinion is that the PandoraOS should start using the feeds for installs of things like this, in which case users can simply use the GUI to add these components themselves.
 
Well the full Java core library eats about 89 MiB so there's that to think about.
Or, well, the library without plugins is 49 MiB...
And GNU Classpath, the version of the core libraries used in Ångström, is only 8.49 MiB...

Or, well, I guess that the package "openjdk-6-common" would be better suited than the GNU Classpath, and OpenJDK clocks in at 25 MiB

Either way, I think it would be worth it to include a J2SE JRE in the Pandora's firmware


Hey, could anyone try to install "openjdk-6-java" and see how much space it actually takes? (If you use an SD card install, you won't cry over the lost megabytes)

EDIT: And it'd also be interesting to find out what the virtual package "java2-runtime" installs per default.
 
dflemstr said:
Hey, could anyone try to install "openjdk-6-java" and see how much space it actually takes? (If you use an SD card install, you won't cry over the lost megabytes)
I installed this package some time ago. It takes about 40MB edit: 80 MB.
 
Last edited by a moderator:
Back
Top