Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 18 of 18

Thread: Embedding an executable .JAR file in a webpage

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Embedding an executable .JAR file in a webpage

    Hi everyone,

    I am desperate for some expert advise about embedding an executable .jar file on a webpage. I am not a programmer and we use Blackboard Publish to package our Blackboard sessions into a standalone executable .JAR file which gives the user the full Blackboard experience. We want to embed this file on our webpage, so I did some research and I understand I have to use a Japplet (?). I have tried putting the basic (J)applet code I found on the web (modified of course) onto the webpage (see code below) but I get a 'ClassNotFoundException' error. I'm not really surprised, but I don't have the ability to define the files that are in the .JAR created by Blackboard Publish. Can someone tell me how I would go about embedding this file? I can look at the files within the .jar with Winzip but there seem to be loads of .class files and I am unclear which one my webpage is trying to find!


    <APPLET CODEBASE="/Blackboard/" ARCHIVE="test.jar" CODE=test.class WIDTH=140 HEIGHT=45>
    <(J)APPLET>

    If it can't be done, then can someone put me out of my misery by letting me know why? All help truly appreciated!!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,955
    Thanks
    56
    Thanked 2,353 Times in 2,324 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Can you copy the full text of the error message and paste it here?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Since my last post I have tried a different .JAR file and what I think is the same code (see below). I no longer get an error but when I look at the page I just see a little java loading picture and a progress bar (see attached). This progresses to the end and then disappears! very frustrating because I feel I must be almost there! Any help?

    <APPLET CODEBASE="../Blackboard/" ARCHIVE="Test.jar" CODE=Test.class WIDTH=140 HEIGHT=45>
    <(J)APPLET>
    webpagejar.jpg

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,955
    Thanks
    56
    Thanked 2,353 Times in 2,324 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Simplify the test by putting the jar file in the same folder with the html file and remove the codebase attribute.

    Copy the contents of the browser's java console and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    And if you aren't sure what the Java console is, this might help: How do I enable and view the Java Console?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Junior Member
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Quote Originally Posted by Norm View Post
    Simplify the test by putting the jar file in the same folder with the html file and remove the codebase attribute.

    Copy the contents of the browser's java console and paste it here.
    Our site is hosted so should I just put the .jar in the root? In the meantime here is the java console data:

    java.lang.ClassNotFoundException: Test.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.initAppletAdapte r(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

  7. #7
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Hi. The exception states that the Java plugin installed in your machine is unable to find a Java class file called Test. This file, Test.class, should be located in your Test.jar file. Open up the jar file with Winzip again and see if you can locate this file. If you can, you also need to take note of the directories in which this file is located. E.g., if it is located in the jar file like this: \com\blackboard\Test.class, then you'll need to modify your HTML code so that it contains

    ... code="com.blackboard.Test.class" ...

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,955
    Thanks
    56
    Thanked 2,353 Times in 2,324 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    java.lang.ClassNotFoundException: Test.class
    The java machine can not find a class named: Test.class. Test.class is a filename, not the name of a class. The class name would be: Test.
    Change the html code= attributes value to Test, leave off the .class
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    You may be right, Norm, but the web is littered with examples (including HTML applet tag) where .class is included. I haven't had the chance to try it out, but perhaps it works either way... Definitely worth trying without .class though.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,955
    Thanks
    56
    Thanked 2,353 Times in 2,324 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    I've seen that the removing the .class has fixed the problem. I haven't collected a list of what browsers require that or in what context there is the problem.
    I've never coded the .class in any html I've used. The doc one finds on the internet mostly says to use the filename (with .class) vs the class name (w/o the .class).
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Thanks both for your efforts to help me! I have tried simply removing the .class from the html but it didn't work. I have looked inside the .JAR and have not found a test.class. There must be well over 40 .class files in there with various paths!! How do I know which one to specify? I'm sure if I can name the correct one it will work (both with the .class in the html and without). Any ideas? I have included a screen shot of the first few .class files listed for your information so you can get an idea of what I mean. img2.jpg

    Thanks for you patience...

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,955
    Thanks
    56
    Thanked 2,353 Times in 2,324 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    How do I know which one to specify?
    Read the documentation for the program or ask the author. Otherwise you need a tool which will tell you which class extends the Applet class and use that one in the code= attribute. Or do a trail and error approach using each one in turn.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    I agree with Norm. A few fundamental questions, if i may:
    1. Where did you get the jar file?
    2. Does the jar file actually contain code for a Java applet? (I.e., you can't embed just any Java application into a web page. It has to be a Java applet.)

    There is a relatively simple way to find out which one of the Java class files extends the JApplet (or Applet for old-school applets) class. The JDK (assuming you have this installed, otherwise install it) comes with a Java Class File Disassembler. See javap - The Java Class File Disassembler. This tool is located in the JDK's bin folder. To run it via command line, you do something like javap C:\<path_to_class_files>\*.class. (Note: I use a Linux desktop, so I can't directly test the command with a Windows path, but it certainly does work on Linux.) This assumes you have already unzipped the jar file.

  14. #14
    Junior Member
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Quote Originally Posted by jashburn View Post
    I agree with Norm. A few fundamental questions, if i may:
    1. Where did you get the jar file?
    2. Does the jar file actually contain code for a Java applet? (I.e., you can't embed just any Java application into a web page. It has to be a Java applet.)

    There is a relatively simple way to find out which one of the Java class files extends the JApplet (or Applet for old-school applets) class. The JDK (assuming you have this installed, otherwise install it) comes with a Java Class File Disassembler. See javap - The Java Class File Disassembler. This tool is located in the JDK's bin folder. To run it via command line, you do something like javap C:\<path_to_class_files>\*.class. (Note: I use a Linux desktop, so I can't directly test the command with a Windows path, but it certainly does work on Linux.) This assumes you have already unzipped the jar file.
    We create the .JAR using Blackboard Publish (our .jar file contains is a recording of an online training session which includes the blackboard control window and not just sound and slides in order to give the viewer the entire experience of the live session). Blackboard have proven rubbish in answering our questions and just say they are unable to help us. THEREFORE I have no idea if the jar file contains code for an applet! We are simply trying to embed this jar file on our webpage and have it stream. Not as easy as it sounds...

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,955
    Thanks
    56
    Thanked 2,353 Times in 2,324 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    So there can be any kind of file in the jar file. There is no requirement that there is any code in it that can be executed either as a desktop app or as an applet. I think you need a java programmer to sort out what you have and to determine if there is any code that can execute and how and where it can execute.
    If you don't understand my answer, don't ignore it, ask a question.

  16. #16
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Going slightly off-topic but... is this what you're referring to by "Blackboard Publish": Blackboard Collaborate | Download Blackboard Collaborate Publish ? If so, it appears that you can convert the recorded session into a movie file format. But since you mentioned having a jar file, did you generate an "unplugged recording"?

  17. #17
    Junior Member
    Join Date
    Feb 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    Quote Originally Posted by jashburn View Post
    Going slightly off-topic but... is this what you're referring to by "Blackboard Publish": Blackboard Collaborate | Download Blackboard Collaborate Publish ? If so, it appears that you can convert the recorded session into a movie file format. But since you mentioned having a jar file, did you generate an "unplugged recording"?
    Yes, thats the one and it is an 'unplugged recording'. The reason we didn't want to convert to a movie is that this only gives the audio and presentations slides and any interaction within Blackboard is not shown.

    Thanks all for attempting to help me!

  18. #18
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: Embedding an executable .JAR file in a webpage

    The installation and user's guide is available via the link at the bottom of the page. Content that can be included in video files is described on page 7 in the guide. On top of that, based on the instructions to launch unplugged recordings using Ubuntu described on page 41, it would appear that the generated jar file is not a Java applet. Instead, the instructions suggest that it's meant to be downloaded into the user's desk/laptop, and executed from there (for Windows, double-clicking on it after downloading should work if Java has already been installed in the machine.)

    In short, it seems that Blackboard Publish does not provide anything to embed and stream videos into a web page as you would with YouTube. It allows the generation of video files, or a standalone executable jar to be downloaded. This is probably why Blackboard said they can't help you with this...

Similar Threads

  1. How to make an executable .jar file?
    By bdennin in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 11th, 2013, 06:22 PM
  2. Cannot create executable jar file
    By viper_pranish in forum Java Theory & Questions
    Replies: 4
    Last Post: March 20th, 2013, 11:31 AM
  3. [SOLVED] no sound from executable jar file
    By cl2606 in forum What's Wrong With My Code?
    Replies: 17
    Last Post: June 8th, 2011, 07:41 PM
  4. Jar Executable File Not Working
    By Kimimaru in forum Java Theory & Questions
    Replies: 6
    Last Post: October 15th, 2010, 10:32 PM
  5. Jar Executable File
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 43
    Last Post: June 23rd, 2010, 04:53 PM

Tags for this Thread