Results 1 to 2 of 2
  1. #1
    Vorsaykal is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default Need Help With Eclipse Applet Viewer

    Could someone explain to me how to run an applet, both in the applet viewer and in Google Chrome, using Eclipse? Also is there an a way to edit the HTML file in Eclipse, rather than using a different editor, such as notepad?

    I am using verson 3.7.1.

    I have my HTML file here:
    XML Code:
    <html>  
     <body>  
            <applet code="SimpleApplet" width=100 height=100>
              <param name="background" value="0x00FF00">
            </applet>  
     </body>  
    </html>
    And Java file here:
    Java Code:
    import java.applet.*;
    import java.awt.*;
    public class SimpleApplet extends Applet {
    	String  background;
    	
    	public void init() {
    		background = getParameter("background");
    	}
    	
    	public void paint(Graphics g) {
    		g.setColor(Color.decode(background));
    		g.fillRect(0, 0, 100, 100);
    	}
    }
    So if I had a Java Project would the HTML file be in src or bin?

  2. #2
    don2109 is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Re: Need Help With Eclipse Applet Viewer

    You can definitely edit a HTML file in eclipse. Right click the file in Package explorer and select 'open with' then 'Text Editor'. I have edited XML files in eclipse and it works very well. I haven't done much with HTML.

    You can run the applet in eclipse also. I haven't done much with applets, but when I created one and clicked the run button, it came up in applet viewer without a problem.

    If you have the applet class file in the same folder as the html file, all you have to do is double click the html file. The os should open the file with your default browser and the applet should run inside the browser. Or in the browser you can just open the html file. Shouldn't matter which browser you use.

    You can also use appletviewer. If you're running windows, open windows explorer and right click the folder containing the html file. Then right click and select 'command prompt here' (or something like that, I don't run windows from home. At work I run XP, I'm doing this from memory. Also I don't know if windows 7 still does this. if this doesn't work you'll need to open a dos window somehow and navigate to that folder.) The dos window opens in that folder. Then set the path:

    path=c:\Program files\Java\....\.bin

    You'll have to find the correct path to your Java bin folder on your computer. Then you can run appletviewer:

    appletviewer filename.html

    Hope this helps.

Similar Threads

  1. applet working in applet viewer, not browser
    By plasticfood in forum Java Applets
    Replies: 4
    Last Post: 06-24-2011, 06:47 PM
  2. Create Applet in Eclipse
    By spac in forum Eclipse
    Replies: 2
    Last Post: 10-20-2010, 05:53 PM
  3. Changing default Applet Viewer Size?
    By dsym@comcast.net in forum Java Applets
    Replies: 6
    Last Post: 08-27-2010, 06:42 PM
  4. java applet viewer dimensions
    By yuriythebest in forum Java Applets
    Replies: 1
    Last Post: 11-08-2008, 10:44 PM
  5. Eclipse Applet Viewer not showing graphics?
    By sjchase in forum Java Applets
    Replies: 1
    Last Post: 04-17-2008, 04:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •