Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help with Java3d embedding

  • 15-10-2008 4:27pm
    #1
    Registered Users, Registered Users 2 Posts: 2,985 ✭✭✭


    Hello there, i'm looking to embed a java3d applet onto a webpage (it wasn't created by me - i'm just doing someone a favour) and dont know much about java!

    He gave me three files: a .class file, a .java file and a .html file. At first it wouldnt run because I hadn't java3d installed on my computer, so I installed it and now it works. Problem is most people wont have it installed on their computers.

    On the java website they say to use an applet launcher which will automatically download the required files, and they provide an example here: https://applet-launcher.dev.java.net/

    However, I dont understand the <param name="subapplet.classname" value="mypkg.MyApplet"> part!! What do I put in instead of mypkg.MyApplet?


Comments

  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    animaX wrote: »
    Hello there, i'm looking to embed a java3d applet onto a webpage (it wasn't created by me - i'm just doing someone a favour) and dont know much about java!

    He gave me three files: a .class file, a .java file and a .html file. At first it wouldnt run because I hadn't java3d installed on my computer, so I installed it and now it works. Problem is most people wont have it installed on their computers.

    On the java website they say to use an applet launcher which will automatically download the required files, and they provide an example here: https://applet-launcher.dev.java.net/

    However, I dont understand the <param name="subapplet.classname" value="mypkg.MyApplet"> part!! What do I put in instead of mypkg.MyApplet?

    You put in the full class name including package prefixes. Ask your mate what the full class name is. You can also figure it out from the .java file. It will be the line that has package a.b.c; appended with the class name which is usually the file name. so if its called Demo.java and the package is com.test, then the full value is "com.test.Demo"


  • Registered Users, Registered Users 2 Posts: 2,985 ✭✭✭animaX


    Thanks for the reply! Problem is i dont know what a package is and i couldn't find the relevant line in the java file. Also, he doesn't know java either!! It was a student of his that created this and she cannot be contacted.

    If I pm'd you the java file could you find the right words to put it?!


  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭none


    Package declaration, if it's present, must be the first executable line in a java file. If there is no explicit package declared, it is in the default one, i.e., no explicit package but rather everything in the current folder will be considered your package. So if your class in the default package, just drop "mypkg" and use
    <param name="subapplet.classname" value="MyApplet"> where "MyApplet" is your class name. You can get the class name from your java file looking for something like
    public class Simple extends Applet
    
    but in most cases your java file as well as your class file will be named after your class.


  • Registered Users, Registered Users 2 Posts: 2,985 ✭✭✭animaX


    Thanks for the reply none. From what I can see, there seems to be a lot of packages initialized in the beginning. The first snippet of code looks like this:
    import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
    import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
    import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import com.sun.j3d.utils.geometry.GeometryInfo;
    import java.awt.GraphicsConfiguration;
    import com.sun.j3d.utils.applet.MainFrame;
    import javax.media.j3d.Locale.*;
    
    
    public class Associahedron extends Applet implements ActionListener
    {
    

    The files are called Associahedron.class, Associahedron.html and Associahedron.java


  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    No package so value for applet classname in html is just "Associahedron"


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,985 ✭✭✭animaX


    lynchie wrote: »
    No package so value for applet classname in html is just "Associahedron"

    I tried that but it still gives an error message "class not found: Associahedron"


  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭none


    Put all your files in one folder and make sure your HTML applet tag looks similar to below:
    <applet	code="Associahedron.class" width="100" height="100">
      <param name="XXX" value="YYY"> ... your params go here
    </applet>
    


  • Registered Users, Registered Users 2 Posts: 2,985 ✭✭✭animaX


    Hi none, I am able to get the applet to run on my computer if I use the applet as you have suggested. But because i'm trying to get it to run on any computer that browses the web page, I need to use the following applet launcher:
    <applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
          width=600
          height=560
          archive="Associahedron.jar,
                   http://download.java.net/media/applet-launcher/applet-launcher.jar,
                   http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dcore.jar,
                   http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dutils.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/java3d/webstart/release/vecmath/latest/vecmath.jar">
       <param name="codebase_lookup" value="false">
       <param name="subapplet.classname" value="Associahedron">
       <param name="subapplet.displayname" value="My Java 3D Applet">
       <param name="jnlpNumExtensions" value="1">
       <param name="jnlpExtension1" value="http://download.java.net/media/java3d/webstart/release/java3d-latest.jnlp">
       <param name="progressbar" value="true">
       <param name="noddraw.check" value="true"> 
     </applet>
    

    as suggested by the official java3d site. The problem is, it gets stuck at
    <param name="subapplet.classname" value="Associahedron">
    

    To be honest i'm getting sick of it not working!! I just edited the html file to hyperlink to the relevant download centre for windows and non-windows user. That way they can install the required files themselves and refresh the browser.

    Thanks everyone for your time and help!


  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    What is the exact contents of Associahedron.jar?


  • Registered Users, Registered Users 2 Posts: 2,985 ✭✭✭animaX


    lynchie wrote: »
    What is the exact contents of Associahedron.jar?

    There is no Associahedron.jar! As I said, all I have is a java, class and html file. Do I have to create Associahedron.jar first? I tried doing that in command promt but it wouldn't work.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    Yes you need the jar file. This is the archive where java will look for those class files.

    assuming the class file is in the current directory running "jar -cvf Associahedron.jar *.class" will create it for you. Jar file is just a regular zip file so u can open it with winzip / 7 zip to check it created it correctly. Make sure you have a java SDK installed or jar wont work. Alternatively, just add the class file to a zip file and rename it to Associahedron.jar


  • Registered Users, Registered Users 2 Posts: 2,985 ✭✭✭animaX


    YES! IT WORKED!! Thanks to everyone. I needed a .jar file. Beautiful!


Advertisement