Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Applet Does not work properly in browser

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I have been away from java for a few years, but I have been back to it for a few months now. I'm working on putting together a web site and I'm at the point where I'm experimenting with using Java applets in a web page. I spent many hours trying to get my own code working with applets, but no luck there. So, I decided to back up and go to examples that I knew, or at least I thought I knew, would work.

I dug out an example from Core Java Volume 1, edition 8, by Hortsmann and Cornell. The example is from chapter 2 of that book and is called 'WelcomeApplet'. There are 2 files, WelcomeApplet.java and WelcomeApplet.html. I compile the java file first. I then run 'appletviewer Welcome.html'. The html code is not displayed, but the applet comes up and displays as expected, meaning that a window pops up, the title is displayed, and two buttons with labels appear.

When I go to my browser (I tried using firefox and chrome), the applet comes up, but only the html is processed. The applet itself does not get processed. Thus, in the browser, I only see the html, but no buttons from the applet class.

I'm having the same problem with the example that I am having with my own code: I cannot get an applet tag in my html file to be processed by the browsers. I'm baffled and I figure I must be missing something obvious. It appears that when the applet tag is read by the browser, it is not finding the WelcomeApplet.class file, but that is a guess. My understanding is that with the html file and class file in the same directory, the class should be found.

I got the example code doing the following:

1) Go to http://horstmann.com/corejava.html
2) scroll down the page to the "Further Information" section
3) At the 2nd bullet item "Download Code:", click on "8th Edition" and download the zip file
4) unzip the downloaded file
5) change director to the v1ch02/WelcomeApplet directory from the unzipped code
6) The files WelcomeApplet.html and WelcomeApplet.java are there to be viewed

Comments and suggestions are most welcome.

Jim Anderson

 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my advice, and you probably won't like it: don't use applets.  They are a very old technology that has been shown to be insecure.  I don't think the Chrome browser even supports applets any more.
 
Master Rancher
Posts: 3876
35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this re browsers and applets: https://java.com/en/download/help/enable_browser.xml

I have a test applet on a website that I am able to open and execute in Internet Explorer on a Win10 system.  I had to reassure IE several times it was OK before it worked:
http://normsstuff.x10host.com/SmallBlob.html
 
Marshal
Posts: 69847
278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but who wants to use appletviewer any more? Maybe we should suggest to Horstmann he change the website next time we see him here.
 
Jim J Anderson
Ranch Hand
Posts: 40
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

@Norm and Knute

Thanks for your input. As I mentioned, I was experimenting. My intent was to evaluate if there is any performance advantage to using applets vs other styles. The fact that the technology is fading away is a good reason to drop this experiment now. Throw in the security risks and it is even a better reason to stop here.

I will close this issue.

Jim
 
Does this tiny ad smell okay to you?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic