gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > New To DS Programming - Wondering If You Can Run Java On DS

#106444 - ElChibo - Thu Oct 19, 2006 2:44 am

Hey everyone, I'm new to programming, and programming on the ds. I was wondering, is it possible to get java to run on the ds, possibly by getting a compiler that will take java code and make it compatible for the ds or something. either way, how can i go from a .java file, to a .nds file

#106445 - Mr. Picklesworth - Thu Oct 19, 2006 4:22 am

As far as I know, nope.
Java is an interpreted language, which means it needs a thing called a runtime environment running on the DS, which there is not.
I guess there could be a compiled Java thing, though. I don't pay much attention to it. (Personally, I very much dislike Java).

If I was you, I'd learn some C or C++ basics, and probably pick up a copy of PA-Lib because it's a nice and easy place to start.

Those two languages are well worth learning, and really not hard to deal with after looking at some examples to straighten it out.

(Of course, getting some experience with it is the most important part to becoming a better programmer! So don't worry too much about reading all the books until you feel that you don't really know something and you want to learn it).
_________________
Thanks!
MKDS Friend Code: 511165-679586
MP:H Friend Code: 2105 2377 6896

#106450 - OOPMan - Thu Oct 19, 2006 7:57 am

Not without writing a JVM, I think. Which is probably not really possible, unless you write one for Java ME...

Alas, if only Nintendo had decided to use an ARM9 with Jazelle, then we could run Java code bare-metal :-(
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#106458 - PypeBros - Thu Oct 19, 2006 8:50 am

<rant>
Omg. They're given shiny processors with the most powerful 2D chip i've ever seen and they ask for JAVA ? ? ?
</rant>

You'd want to fit a JVM with garbage collecting on a 66MHz using 4MB of RAM ? I'm not saying it cannot be done, but what would it be good for? (please don't answer something about web browsing)
_________________
SEDS: Sprite Edition on DS :: modplayer

#106468 - kusma - Thu Oct 19, 2006 12:27 pm

IIRC, the gcc-java-thingie has an option to to output native code. This could theoretically be used to generate ARM-code, but somehow I doubt it'd work "right out of the box" ;)

check out these links:
http://gcc.gnu.org/java/
http://ulibgcj.sourceforge.net/

edit: added some links

#106487 - tepples - Thu Oct 19, 2006 5:34 pm

But would the standard libraries work, given the lack of threading and GUI routines in the library that comes with devkitARM?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#106493 - OOPMan - Thu Oct 19, 2006 7:05 pm

I'm not sure about the gcc-java thing, but all java compilers produce native code. Native Java code. Ie. Code native to the Java virtual machine specification.

Cerain processors, including ARMs with Jazelle support, can run this code natively. However, as I mentioned above, the ARMs used in the NDS do not support Jazelle.

Hence a JVM for the ARM would need to be produced and that's likely to be a lot of work.

The ARMs used in Nokia phones, among others, do support Jazelle, which is why they can run Java code in the first place :-)
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#106502 - Izhido - Thu Oct 19, 2006 8:32 pm

You know, if you have time to spare, these guys have something to say:

http://www.wabasoft.com/

Check the top headline. Interesting, huh? :)

Waba's been around here for quite some time ago. They proved that you can make a VM portable enough for running on almost all devices. In fact, I felt encouraged enough from them to make myself think about creating a portable CLR runtime (something I'll start soon enough, I hope). So, yes, if you have the time to download & port Waba to the DS, it should be possible to run Java code on it.

#106504 - kusma - Thu Oct 19, 2006 8:46 pm

OOPMan wrote:
I'm not sure about the gcc-java thing, but all java compilers produce native code. Native Java code. Ie. Code native to the Java virtual machine specification.


VM byte code is generally not what is considered native code. If it needs to be translated before running, it's not really native, is it? GCJ can produce native code for the ARM (among other host-cpus).

OOPMan wrote:

Cerain processors, including ARMs with Jazelle support, can run this code natively. However, as I mentioned above, the ARMs used in the NDS do not support Jazelle.


Jazelles can't run all Java byte code, it's just an instruction-set optimized for Java execution. You'll need a Jazelle-aware JVM to take advantage of it. In fact, ARM markets Jazelle as a combined software and hardware solution. It also only supports Java ME AFAIK.

OOPMan wrote:

Hence a JVM for the ARM would need to be produced and that's likely to be a lot of work.


Not if you're able to produce a native binary in advance. See my first comment.

OOPMan wrote:

The ARMs used in Nokia phones, among others, do support Jazelle, which is why they can run Java code in the first place :-)


Only some of them do. In fact, the first cellphones to run Java did not have any kind of java-specific acceleration, while still being quite small.

#106530 - OOPMan - Fri Oct 20, 2006 7:59 am

Har, well, I bow before your superior knowledge kusma :-)

That said, compiling Java into native ARM binary code is kinda missing the point with java. You now, that whole Write-Once-Run-Anywhere thang...

Although I'd imagine a Java program for the DS would require various specific features anyway, hence WORA isn't really applicable anyway :-)
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#106534 - PypeBros - Fri Oct 20, 2006 9:13 am

Speaking of JAVA on ARM, there was the Jeode project running on my ARM-powered Sharp Zaurus. Performance were pitiful, though and the Zaurus -- despite having a weaker media chipset -- had more memory and processing power than the DS (afaik)
_________________
SEDS: Sprite Edition on DS :: modplayer

#106550 - silent_code - Fri Oct 20, 2006 2:55 pm

as soon as you start some serious work and a bigger software system you can forget about WORA, even in the pc space. there's always some porting included once it get's a bit more involving.

just my 5 ct

#106554 - ps2aich - Fri Oct 20, 2006 3:40 pm

ElChibo wrote:
Hey everyone, I'm new to programming, and programming on the ds. I was wondering, is it possible to get java to run on the ds, possibly by getting a compiler that will take java code and make it compatible for the ds or something. either way, how can i go from a .java file, to a .nds file


For example, there was a guy that stated he has ported a j2me kvm (kvm means kilobyte-vm, thats a restricted java virtual machine with less memory and performance footprint for devices like cell phones etc)
to the PSP (which has 32MB of memory as far as I know): http://pspupdates.qj.net/Introducing-PeeJay-Java-on-your-PSP-/pg/49/aid/67665

What he has done is, taking the sources of the kvm (yes the sources are
available through Sun) and adapted some device specific stuff.
BUT: java is not opensource in means of an open source license like apache or gnu yet, so you need the allowance of SUN to
make such a port public.

So, running a Java KVM with a small device profile may be perhaps
possible, but I think the main problem is the amount of memory, since
the DS has only 4 MB of it that has to be shared by the vm and the java programs: that means many standard java programs will not run, and many java programs for smaller devices like cellphones are perhaps
to specific to the cellphone hardware capabilities (like the numpad).

#106561 - OOPMan - Fri Oct 20, 2006 5:09 pm

silent_code wrote:
as soon as you start some serious work and a bigger software system you can forget about WORA, even in the pc space. there's always some porting included once it get's a bit more involving.

just my 5 ct


Wel, if you start using JNI, then yes.

But assuming you stick to pure Java and there aren't any bizarre differences between the VMs on various platforms, Java is pretty much WORA...

If you need to use JNI then it might be better to just do a pure C/C++ implementation...

EDIT: With regard to p2aich's post, memory problems can be gotten around by using the additional memory provided by the SC and M3 devices. In such a sitution one might run the cut-down VM in the main memory, while using the additional memory to store program data, etc...
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#106566 - tepples - Fri Oct 20, 2006 6:02 pm

OOPMan wrote:
But assuming you stick to pure Java and there aren't any bizarre differences between the VMs on various platforms, Java is pretty much WORA...

But there are in fact differences among VMs, largely in areas of the implementation of java.io, java.awt, javax.swing, and anything else used for input and output.

Quote:
EDIT: With regard to p2aich's post, memory problems can be gotten around by using the additional memory provided by the SC and M3 devices.

Such a solution does not generalize to licensed development, where not every customer has Opera and its RAM pack. Don't rely on this if you're looking for employment as a DS programmer.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#106605 - OOPMan - Sat Oct 21, 2006 9:06 am

Hmmmmm tepples, it's a pitty that those damn VMs have their differences, then. Perhaps sticking with Sun's base implementations is not such a bad idea then? One can at least be fairly sure Sun's JVM for Windows will support the same things as the Linux release :-)


As for
Quote:
Such a solution does not generalize to licensed development, where not every customer has Opera and its RAM pack. Don't rely on this if you're looking for employment as a DS programmer.
...

Erm, when did we start talking about licensed development?

I thought the subject was, basically, porting a JVM to the NDS via the homebrew pathway. I don't recall saying anything about seeking employment as a DS coder...

Are you perhaps replying to something else someone said and misattributing the quote or something?
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...

#106786 - Dwedit - Mon Oct 23, 2006 11:48 am

There's the QS Moka Java to C converter for the TI89, which is far less powerful than a DS.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#106995 - Izhido - Wed Oct 25, 2006 4:11 pm

Hehe. Astounding. How does a post talking about Java suddenly becomes a post about being hired to work in another country? Oh well, what's one gotta do?

So, anyone got a chance to test Waba's GB port? Or better yet, is someone already porting Waba to the DS? Just being curious...

#107051 - tepples - Thu Oct 26, 2006 12:01 am

Professional development discussion splitoris.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#107073 - OOPMan - Thu Oct 26, 2006 8:21 am

Well, some notes on WabaVM. Porting basically involves bulking out 3 C files with various functions that handle various things. Some of this is pretty easy, mainly just platform specific stuff for memory zeroing/coping/etc type functions.

Another key part is the creation of a main program loop for the VM, which mainly just seems to handle input and pass it to the VM code.

There's also code that looks like any porting to the DS would have to implement a basic window system...

Well, anyway, good luck to whoever gives it a go :-)
_________________
"My boot, your face..." - Attributed to OOPMan, Emperor of Eroticon VI

You can find my NDS homebrew projects here...