0

I wanted to apologize for the question I figured it out it was the codebase but also an issue with eclipse after changing:

codebase="F:\Apps Workspace\Java24\bin"

as well as changing the use of the internal web browser to the external web browser and making it IExplorer it worked fine thank you for your time and sorry again.


I'm currently learning Java by reading "Sam's teach yourself Java in 24 hours" book currently I'm on the 19th hour and working on an example applet. I've followed the book so far without issues until this chapter and chapter hour 18, which is on Applets.

My current issue is testing the Applets in the book he is using Netbeans and I am using Eclipse, the sole reason I'm currently using eclipse is to become comfortable with it the next book I will be working on is Android programming which is where they use only eclipse.

My issues is when the book talks about testing the applet we've made it says to make a HTML file to test the applet. The html code is this:

<applet code = "LinkRotator.class"
        codebase = "..\\build\\classes"   <===This is where I think my issue is.
        width = "300"
        height = "100">
</applet>

Now when I save the HTML and have it open in eclipse I just get a blank white page, and from what I have read on google searches the codebase is the location of the folder or item in this case LinkRotator.class would be in. I've tried changing it multiple times but still no dice. Now the folder this is located in is on F:\Apps Workspace\Java24\bin\LinkRotator.class. The strange thing is I have installed Netbeans to see if it would work there if I just moved the files there and it still did not run.

So my main question is how would I make this html file point point correctly at the applet I'm working on and have it load properly in eclipse?

Two more things, I can run the Applets by just hitting run in eclipse but I'm just trying to make it load from the web page like the book states. Also for anyone wondering about more info the website with copies of the work can be found here.

Roman C
  • 49,761
  • 33
  • 66
  • 176

2 Answers2

0

Try the following steps:

In the Package Explorer, select the Java compilation unit or class file containing the applet you want to launch. Press the Run [ ] button in the workbench toolbar or select Run > Run from the workbench menu. Alternatively, select Run As > Java Applet from the Package Explorer pop-up menu, select Run > Run As > Java Applet in the workbench menu bar, or select Run As > Java Applet in the drop-down menu on the Run tool bar button. Your program is now launched.

Kds23
  • 307
  • 1
  • 3
  • 8
0

The applets are supposed to deploy on the server and run on the client. If you are creating the applet project in Eclipse then the default project html should be created by the wizard. So, you can launch it from the IDE or from the appletviewer on the local side. The <applet tag is deprecated and use

CODEBASE = codebaseURL This OPTIONAL attribute specifies the base URL of the applet--the directory that contains the applet's code. If this attribute is not specified, then the document's URL is used.

should be a valid URL. An Example that <object tag

  <object id="appletId" type="application/x-java-applet" archive="yourappletcode.jar" height="300" width="400">
    <param name="code" value="YourApplicationmainClass" />
    <param name="archive" value="yourappletcode.jar" />
  </object>

better to use an archive your code into the jar before deploy it on the server.

Roman C
  • 49,761
  • 33
  • 66
  • 176