Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't run my own Java Applets on browser!

    Hi guys,

    I'm learning about coding applets in Java. I'm using the NetBeans IDE (6.5) to do my programming. When I run the applets in the "Applet Viewer" that NetBeans provides, it works just as you'd expect; however, when I try to run it in my web browser, it doesn't work at all. The browser (Firefox 3.6.17) tells me, "Loading Java Applet Failed".

    Now, when I go to any other website with java applets, they work without any problems. I have Java enabled, so that's not an issue.

    I've tried looking online for a solution, but can't find anything. Hopefully someone can help me out.

    I'm using a Mac OS X 10.4.11, 1.83 GHz, Intel Core Duo, and the Java on my browser is version 1.5.0_19. This is not working in both Firefox 3.6.17 and Safari 4.1.3.

    Please Help!!

  • #2
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found out that when I use the Terminal to compile the .java source code and run that with a simple html file, it works in the applet viewer and in the browser. So that means, the problem is definietly with NetBeans.

    Any fellow NetBeans users ever encounter the same problem?

    This issue is still unresolved because I'd like to be able to run my applets directly from NetBeans if possible!

    Here is the code:


    SalutonApplet.java:

    Code:
    import java.awt.*;
    
    public class SalutonApplet extends javax.swing.JApplet {
        String greeting;
        //GridBagLayout grid = new GridBagLayout();
    
        public void init() {
            //this.setLayout(grid);
            greeting = "Saluton mondo!";
        }
    
        public void paint(Graphics screen) {
            Graphics2D screen2D = (Graphics2D) screen;
            screen2D.drawString(greeting, 25, 50);
        }
    }

    SalutonApplet.html:

    Code:
    <HTML>
    <BODY>
    <APPLET CODE=SalutonApplet.class WIDTH=200 HEIGHT=100>
    
    </APPLET>
    
    </BODY>
    </HTML>

  • #3
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    254
    Thanks
    1
    Thanked 63 Times in 63 Posts
    Tried your code and it ran fine for me (tested on chrome, FF, safari); although safari crashed after it loaded the applet (still displayed the text and all).
    Using netbeans 6.9, java1.6

    Maybe this can shed some light. Quote from http://netbeans.org/kb/docs/web/applets.html
    Select the desired Source / Binary Format for the project.
    Note. For example, if you choose JDK 1.6 the applet might not run on machines that have an older version of the JRE or Java browser plugin.


  •  

    Posting Permissions

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