Archived

This topic is now archived and is closed to further replies.

[java] DirectX and Java

This topic is 5895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering if any of yo know if DirectX methods or functions ro whatever can be called in Java. I know they have a Microsoft SDK for Java, but I don''t think you can call DirectX in it. In fact, i think its only for Microsoft Internet Explorer. If anyone knows any way to call DirectX stuff in Java, please HELP!!!!! thx

Share this post


Link to post
Share on other sites
Hi There,

You CAN call certain DirectX methods under Java - I think they are indeed included in the MS SDK for Java (although I can''t be 100% sure - it''s a long time since I tried this).

They are however limited so you may want to look into using Sun''s JDK as the later versions now have things like hardware support and full-screen.

HTH



Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think the only way to call DirectX from Java would be through JNI (Java Native Interface) calls (this is also how graphics are handled in Sun''s Java implementation for Windows). Microsoft did create some language that resembled Java but lacked JNI and was tied to the Windows platform so the court decided that Microsoft may not call that language Java. Anyway, that language, whatever Microsoft calls it these days (J++? C#? J#?), had some other way of calling Window''s APIs but we are discussing Java here, right?

Henry

Share this post


Link to post
Share on other sites
Here''s the deal:

In MSJava (the version of Java you get when compiling in Visual J++), you can create and call into any COM object. This includes all of DirectX. But with the settlement of the Sun vs MS case, MS has decided to drop Java completely, so this technology is essentially dead.

Java 3D does not provide a Java implementation of the DirectX API. Java 3D is it''s own high-level API. Sun has created implemntatons of this API that use DirectX and OpenGL for hardware access, so if you use Java 3D there might be DirectX running underneith it, but you cannot access it directly.

The only way to access DirectX directly from Java is through JNI as the AP said. Of course, this makes your app un-portable (or portable only to platforms that you port your C code to), ruins the chance of having your app run in the browser (no JNI in the browser, security measure), and really removes any reason to write it in Java (since you''re writing a bunch of C code anyways and you''ve forsaken protablility).

I think I heard somewhere of an open-source project that was trying to write a JNI DLL to make COM objects usable from Java, but I can''t remember what it was called or anything.

"If consquences dictate our course of action, it doesn''t matter what''s right, it''s only wrong if you get caught."
- Tool

Share this post


Link to post
Share on other sites
quote:
Original post by WayfarerX
The only way to access DirectX directly from Java is through JNI as the AP said. Of course, this makes your app un-portable (or portable only to platforms that you port your C code to), ruins the chance of having your app run in the browser (no JNI in the browser, security measure), and really removes any reason to write it in Java (since you''re writing a bunch of C code anyways and you''ve forsaken protablility).



That''s not really true. Only the game library will be written in C/C++, once this has been written it can be used over and over again or you can use a third party library like 6DX. Java has the advantage of providing increased productivity and less headaches that C/C++ as well as having a very nice API which is set to get even better with JDK 1.4.

As for portability, for most this isn''t really an issue. Well, for me it''s not anyway. And while applets are nice in theory, being limited to JDK 1.1 running on a M$ JVM is a major hassle and no one is going to bother to download the Java Plug-In.

- Kaijin

"If you find a job that you love you''ll never have to work again."

Share this post


Link to post
Share on other sites
quote:
Original post by Kaijin
That''s not really true. Only the game library will be written in C/C++, once this has been written it can be used over and over again or you can use a third party library like 6DX. Java has the advantage of providing increased productivity and less headaches that C/C++ as well as having a very nice API which is set to get even better with JDK 1.4.



Don''t get me wrong, I''m one of the biggest Java supporters on these boards, and I agree 100% with the less headaches statement. But when you''re writing the amount of C code you''ll need to do a game (obviously dependant on the specific project), I start to question the viability of invoking the resource drain caused by the JVM to run only a small part of the application. However, this is mostly personal opinion (I should have stated this above).

quote:

As for portability, for most this isn''t really an issue. Well, for me it''s not anyway. And while applets are nice in theory, being limited to JDK 1.1 running on a M$ JVM is a major hassle and no one is going to bother to download the Java Plug-In.



Maybe portablility doesn''t seem like such a big deal now, but you''ve got to keep your eye on the horizon. What about when the javax.games package is released and the JVM appears on the PS2? Do you really want to re-write all your C code to run on the Emotion Engine, or just plop your bytecodes down and go? Same goes for continually evolving PC hardware and the hundreds of new devices released every year.

JNI is Good, but I think the descision to use it must be made carefully. Just be sure to understand the parts of the Java language you''re sacrificing.

"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool

Share this post


Link to post
Share on other sites
Hi!

If you want to use COM from Java you could try the JACOB. This is a port of MS Java classes that works for several JVMs. I have only done minor tests with it, so I can''t say anything about how good it is. So if you are willing to sacrifice the portablility this may be the solution for you.

http://danadler.com/jacob/

Regards
Johan

Johan Karlsson

Share this post


Link to post
Share on other sites