Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

27. May 2012, 12:31:02 am
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Applet development
Pages: [1]
Print
Author Topic: Applet development  (Read 1805 times)
Jimphraxia
Just dropped in

Offline Offline

Posts: 5


View Profile
« on: 05. September 2007, 12:59:50 am »

Hey all,

I'm trying to develop an (admittedly small) Java applet for someone. Basically, I need a 3d, textured book that the user can rotate, that'll be embedded on a web page and parameterised so that the images and size of book can change. That's the part I can do... or, rather, that's the part I managed to bung together at 4am the other night using Java3D, only to realise that unless you have the Java3D plugin installed (which most of the users won't), you're not going many places.

So I came here. I don't need help with the actual 3d coding, per se, I can manage that part well enough. What I am having problems with is getting together a Java applet that I can later embed into a webpage. I've never actually coded in Java before about 3 days ago. I've scoured the forums, and this is what I've managed to pick up:

* I need to use AWT
* I need a panel in the AWT layout
* I need to make a Canvas3DPanel object that then sits inside said panel, or is add()ed like a normal panel?
* Said Canvas3DPanel then gets added to the environment like a normal Canvas3D, using addCanvas()
* I probably need to use the JNLPAppletLauncher and add some jar files as archives once I deploy the applet to the web

Other than that, I'm feeling quite lost. How exactly would I go about the above? Have I got my concepts right? Am I using the right functions and classes? And is there anything else I need to bear in mind when writing an applet?

Thanks in advance
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 05. September 2007, 01:32:34 am »

Hi, Jimphraxia. Welcome to Xith3D Smiley.

Don't dispond Smiley. Your setup looks good. Though you'll only need a Canvas3DPanel and add it to the Applet, since the Canvas3DPanel already is an AWT Panel.

Unfortunately I've never written an Applet. One says, that JavaWS is to be preferred. So I cannot be of more help. But I do know, there are other users here, who have managed to setup an Applet with Xith3D. When they come here, they will certainly complete myself.

I guess, if you already know, how to setup a regular Applet and you know how to deplay additional jars with it, you're already through. You would only need JOGL's natives in a jar and Xith's jars + dependencies. Should run without problems.

Good luck.

Marvin
Logged
Jimphraxia
Just dropped in

Offline Offline

Posts: 5


View Profile
« Reply #2 on: 05. September 2007, 03:10:58 am »

Hey Marvin, thanks for the warm welcome. =)

I've got a basic applet running in Eclipse now, however, I set up all the .jar file dependencies and am now getting a security error when I try embedding it to HTML:

java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs)

Any idea what this may be caused by, or the workaround for it? I'll post all of the error output if needed, but was just wondering if it's a common mistake or something I've overlooked.

Also, upon making a build of the source files, I noticed that there's an error on the current SVN for org.xith3d.test.texture.MultitextureTest:

https://xith-tk.svn.sourceforge.net/svnroot/xith-tk/trunk/src/org/xith3d/test/texture/MultitextureTest.java

There's a trailing comma on line 76, after your name, that's screwing up the parsing. I guess that counts as my little bit to profiting the Xith community thus far. =P

Thanks for the help!
Logged
kukanani
Fierce Warrior
****
Offline Offline

Posts: 504


My game is coming along fairly smoothly...


View Profile WWW
« Reply #3 on: 05. September 2007, 05:49:15 am »

This is caused by security issues (suprise, suprise) about your applet.  Basically, your applet and all associated .JARs need to be signed digitally before they can access other files, i.e. the Xith .JARs, or image files, especially on the user's computer (you don't want to be accused of hacking, do you?  Smiley).

You can learn more about signing jars here:
http://java.sun.com/docs/books/tutorial/deployment/jar/signindex.html

But I can tell you right now, digital signing is not (that's a big NOT) for the faint-hearted.

Good Luck!

Kukanani
Logged

xith.setCoolnessLevel(10);
jMe.setCoolnessLevel(0);
xith.rock();
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #4 on: 05. September 2007, 07:18:16 am »

BTW, automatic management of applet signing would be an interesting feature in OneClick.

Oh I almost forgot : Welcome to Xith3D, Jimphraxia !! If later you release your work it would be appreciated.. we could transform it into an example for the XIN (Xith In a Nutshell), for example..
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #5 on: 05. September 2007, 07:59:54 am »

If you use the JNLP applet launcher to register the "official" JOGL and GLUEGEN extension you may not need to sign your jars. Just leave out the jogl/glugen dependencies and all other natives from the xith distribution. See https://jogl-demos.dev.java.net/applettest.html for more information how to do this.
Logged

Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #6 on: 05. September 2007, 10:44:36 am »

Also, upon making a build of the source files, I noticed that there's an error on the current SVN for org.xith3d.test.texture.MultitextureTest:

https://xith-tk.svn.sourceforge.net/svnroot/xith-tk/trunk/src/org/xith3d/test/texture/MultitextureTest.java

There's a trailing comma on line 76, after your name, that's screwing up the parsing. I guess that counts as my little bit to profiting the Xith community thus far. =P

Well, I've removed that comma. It shouldn't irritate any parser. Even if I would have removed it, if I had recognized it Wink. A comma after the last entry in an array initialization is legal in Java (for convenience). Which parser/compiler do you use.

Marvin
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #7 on: 05. September 2007, 01:41:19 pm »

Sure, new int[] {0, 1, 2, 3, 4,}; is legal. Same thing for enums.
I'm interested too, Jimphraxia, which parser are you using ?
Logged
Jimphraxia
Just dropped in

Offline Offline

Posts: 5


View Profile
« Reply #8 on: 05. September 2007, 03:45:24 pm »

Hm, I'll give the JNLP Applet launcher a try, see if it gives me any joy. And, yes indeed, I was gonna post up some source code when I got it done, I would've been on top of the world if someone had posted up a basic Applet shell here, so if I manage to get anything working I'll let you know. I promise nothing, though, I don't have much practical coding experience.

And I'm not using anything weird, just Eclipse with Ant to build everything... it came up with an error, so I looked at the file it pointed at and found that, and removing the comma solved things.
Logged
Jimphraxia
Just dropped in

Offline Offline

Posts: 5


View Profile
« Reply #9 on: 05. September 2007, 06:47:10 pm »

Ok, just tried to make it work with the JNLP Applet Launcher to no avail. Still getting the same security message.

I'm thinking of reverting to some more quick and dirty methods, seeing as the program doesn't actually need full 3D functionality, and I need to get this thing off the ground soon. Since I only need a single rotating textured cuboid, I may try using JAI with some perspective transforms and work from there. Does anyone know if I'll have the same problems I had using Java3D (i.e., does JAI require a plugin to run like Java3D, or can I just add the .jar file to the archive parameter of the applet?)

Thanks
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #10 on: 05. September 2007, 06:55:05 pm »

Never heard of JAI.

Marvin
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #11 on: 05. September 2007, 09:46:11 pm »

Ok, just tried to make it work with the JNLP Applet Launcher to no avail. Still getting the same security message.
Maybe the security message is not triggered by the 3D part, but by trying to accessing files on the clients machine, setting reserved system properties etc. Post the full stacktrace and your applet configuration if you are still interested in tracking this down...

I'm thinking of reverting to some more quick and dirty methods, seeing as the program doesn't actually need full 3D functionality, and I need to get this thing off the ground soon. Since I only need a single rotating textured cuboid, I may try using JAI with some perspective transforms and work from there.
You can use jPCT for that. It's a pure software renderer that even works with Java 1.1. (Maybe someone wants to jump in and write a Xith-Renderer on top of it Wink)
« Last Edit: 05. September 2007, 09:49:46 pm by Mathias 'cylab' Henze » Logged

Jimphraxia
Just dropped in

Offline Offline

Posts: 5


View Profile
« Reply #12 on: 09. September 2007, 11:24:22 pm »

Sorry about the downtime, I've been away for a while. Ok, I uploaded a test program to the webserver to see if it was just Java being bitchy about reading files off my PC, but no such luck. Here's a dump of the errorlog:

Code:
JNLPAppletLauncher: static initializer
os.name = windows xp
nativePrefix =   nativeSuffix = .dll
tmpRootDir = C:\DOCUME~1\Christy\LOCALS~1\Temp\jnlp-applet\jln24323
Applet.init
subapplet.classname = Test
subapplet.displayname = JOGL / JOAL Gears Applet
Applet.start
os.name = windows xp
os.arch = x86
processNativeJar: http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl-natives-windows-i586.jar --> C:\Documents and Settings\Christy\.jnlp-applet\cache\www_gileadbooks_com\465578166be3f0ebf2691ec0ca618c79b0ce9b9e\jogl-natives-windows-i586.jar : 60716 bytes written
validateCertificates:
VALIDATE: jogl.dll
VALIDATE: jogl_awt.dll
VALIDATE: jogl_cg.dll
extractNativeLibs:
EXTRACT: jogl.dll(jogl)
EXTRACT: jogl_awt.dll(jogl_awt)
EXTRACT: jogl_cg.dll(jogl_cg)
processNativeJar: http://download.java.net/media/gluegen/webstart/gluegen-rt-natives-windows-i586.jar --> C:\Documents and Settings\Christy\.jnlp-applet\cache\www_gileadbooks_com\465578166be3f0ebf2691ec0ca618c79b0ce9b9e\gluegen-rt-natives-windows-i586.jar : 4786 bytes written
validateCertificates:
VALIDATE: gluegen-rt.dll
extractNativeLibs:
EXTRACT: gluegen-rt.dll(gluegen-rt)
processNativeJar: http://download.java.net/media/joal/webstart/joal-natives-windows-i586.jar --> C:\Documents and Settings\Christy\.jnlp-applet\cache\www_gileadbooks_com\465578166be3f0ebf2691ec0ca618c79b0ce9b9e\joal-natives-windows-i586.jar : 222095 bytes written
validateCertificates:
VALIDATE: joal_native.dll
VALIDATE: OpenAL32.dll
VALIDATE: wrap_oal.dll
extractNativeLibs:
EXTRACT: joal_native.dll(joal_native)
EXTRACT: OpenAL32.dll(OpenAL32)
EXTRACT: wrap_oal.dll(wrap_oal)
java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
at sun.applet.AppletSecurity.checkPackageAccess(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.xith3d.render.Canvas3DPanel.<init>(Canvas3DPanel.java:355)
at Test.<init>(Test.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.jdesktop.applet.util.JNLPAppletLauncher.startSubApplet(JNLPAppletLauncher.java:1874)
at org.jdesktop.applet.util.JNLPAppletLauncher.access$200(JNLPAppletLauncher.java:650)
at org.jdesktop.applet.util.JNLPAppletLauncher$5.run(JNLPAppletLauncher.java:1261)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
10-Sep-2007 00:14:20 org.jdesktop.applet.util.JNLPAppletLauncher displayError
SEVERE: Unable to start JOGL / JOAL Gears Applet

And the html used for the JNPL config:

Code:
<html>
<head></head>
<body>
 <applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
      width=600
      height=400
      archive="test.jar, xith3d.jar, xith3d-tk.jar, jagatoo.jar, hial.jar, openmali.jar, http://download.java.net/media/applet-launcher/applet-launcher.jar, http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar, http://download.java.net/media/gluegen/webstart/gluegen-rt.jar, http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl-demos.jar, http://download.java.net/media/joal/webstart/joal.jar, http://download.java.net/media/joal/webstart/joal-demos.jar">
   <param name="codebase_lookup" value="false">
   <param name="subapplet.classname" VALUE="Test">
   <param name="subapplet.displayname" VALUE="JOGL / JOAL Gears Applet">
   <param name="noddraw.check" value="true">
   <param name="progressbar" value="true">
   <param name="jnlpNumExtensions" value="2">
   <param name="jnlpExtension1"
          value="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp">
   <param name="jnlpExtension2"
          value="http://download.java.net/media/joal/webstart/joal.jnlp">
 </applet>
</body>
</html>

I tried using jPCT before I came to Xith, but I gave up because you can only generate cuboids with square faces (i.e. you can only make 3d extrusions of a square, not an actual cuboid by specifying a width, height and depth). I may have to go back to it and use a model importer, however, if it's as simple to use as you say. What I liked about the Java3D version of the script I managed to make was that I could pass image names and dimensions to it as parameters through the html of the page, but I guess when it comes down to difficulties like it has, I can't afford to be picky.

And JAI is Java Advanced Imaging, but it seems to require a plugin like Java3D, and so isn't really an option here.

Thanks for all your help. =)
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #13 on: 10. September 2007, 03:27:54 pm »

Does the Gears-Applet (https://jogl-demos.dev.java.net/applettest.html) work for you? If yes, leave out joal for a start and put your Applet in a package (e.g. jimphraxia.applettest.Test instead of Test). I don't know, if toplevel classes are forbidden for applets, but it's a bad style anyway.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic