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 8 of 8

Thread: Java applet error: "Blocked Exception"

  1. #1
    Member
    Join Date
    Mar 2013
    Posts
    47
    My Mood
    Amused
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Question Java applet error: "Blocked Exception"

    HI everyone! It has been a while now, but I have encountered a problem testing Java applets.

    The error I'm getting is "Blocked Exception" as you can see and I realy have no clue why. here's my code:
    html site:
     
    <html>
    <head>
        <meta http-equiv="Content-Type" content"text/html; charset=utf-8">
    </head>
    <body>
    <applet archive="JavaDisseroappTest.jar"
        width="809" height="500" code="JavaDisseroappTest.class">
    </applet>
    </body>
    </html>


    Java code:
    package javadisseroapptest;
    import java.awt.*;
     
     
     
    public class JavaDisseroappTest extends javax.swing.JApplet{
     
        public void init(){
     
        }
     
     
     
    public void paint(Graphics g){
        Graphics2D g2D = (Graphics2D) g;
        g.setColor(Color.RED);
        g.fillRect(0, 0, 809, 500);
        g.setColor(Color.WHITE);
        g.drawString("THIS IS JUST A TEST FOR THE DISSERO PROJECT :< ", 25, 25);
    }
    }


    Thanks in advance!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,642
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Java applet error: "Blocked Exception"

    Can you copy the full text of the error messages and paste it here.

    Thread moved to applets area from android area

    The code= attribute should have the full class name which includes the package name:
    code=javadisseroapptest.JavaDisseroappTest
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Mar 2013
    Posts
    47
    My Mood
    Amused
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default Re: Java applet error: "Blocked Exception"

    UPDTAE (I tried to fix it, created new files etc, so here are the current files/errors):

    HTML:
    <script src="http://www.java.com/js/deployJava.js"></script>
    <script>
        var attributes = {
            code:'introductapplets.IntroductApplets.class',
        width:700, height:500} ;
        var parameters = {}; // does the Applet take parameters?
        var version = '1.6' ; // does the Applet require a minimum version of Java
        deployJava.runApplet(attributes, parameters, version);
    </script>

    JAVA:
    package javapplettest;
    import javax.swing.JApplet;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JButton;
     
     
     
    public class JAvAppletTest extends JApplet{
     
     
        public void init(){
            GuiButton gui = new GuiButton();
            add(gui);
               }
     
     
     
     
     
     
     
     
     
    }


    Can you copy the full text of the error messages and paste it here.
    Do you mean this(from the java console):
    Java Plug-in 10.25.2.17
    Använder JRE-version 1.7.0_25-b17 Java HotSpot(TM) Client VM
    Användarens hemkatalog = C:\Users\MyNAME
    ----------------------------------------------------
    c: rensa konsolfönster
    f: slutför objekt i slutförandekö
    g: skräpinsamling
    h: visa det här hjälpmeddelandet
    l: dumpa klassladdarlista
    m: skriv ut minnesförbrukning
    o: triggerloggning
    q: dölj konsol
    r: ladda policykonfiguration igen
    s: dumpa system- och distributionsegenskaper
    t: dumpa trådlista
    v: dumpa trådstack
    x: rensa klassladdarcache
    0-5: ange spårningsnivån till <n>
    ----------------------------------------------------
    Everything is in swedish though :1

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,642
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Java applet error: "Blocked Exception"

    What program reads the <script> statements?
    Where is the reference to the applet class that is supposed to execute?

    What command are you using to execute the applet?


    BTW the .class at the end is not part of the class name. .class would be the extension for the filename.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Mar 2013
    Posts
    47
    My Mood
    Amused
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default Re: Java applet error: "Blocked Exception"

    I followed a random tutorial (yeah, I'm was kind of desperate. I don't even remember the site but I think it was sun) which stated that the preferable way to launch applets was with javascript. I did what they told me. I probably needed my own javascript but I didn't know how to and the code yielded the same result so I thought it didn't matter, gave up and created the previous post :/

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,642
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Java applet error: "Blocked Exception"

    Try using the html in the first post with the correct classname and with the class file in the folder with the package name. The html file should be in the same folder that the package folder is in.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Member
    Join Date
    Mar 2013
    Posts
    47
    My Mood
    Amused
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Default Re: Java applet error: "Blocked Exception"

    I keep getting a "BlockedException", but I think I have everything set up.

    I have a folder which contains:
    1. the java package (now named javapplettest)
    2. the jar named JAvAppletTest
    3. the html site with the code:
    <html>
    <head>
        <meta http-equiv="Content-Type" content"text/html; charset=utf-8">
    </head>
    <body>
    <applet archive="JAvAppletTest.jar"
        width="809" height="500" code="javapplettest.JAvAppletTest.class">
    </applet>
    </body>
    </html>

    and the java package folder contains:
    1. JAvAppletTest.class
    2. another subclass which isn't important now I think. Since it will be executed by the JAvAppletTest class.

    At first, when I tried to see if it worked, it actually displayed a java logo sign which dissepeared quickly and gave me the error "ClockedException".

    This html file contains: "applet archive="JAvAppletTest.jar" " but is it really neccisary to give the .jar file when the browser is only going to use the class files? I assume.

    Maybe it's a problem with my computer, though I doubt that since I can run other applets, but I'm clueless as usual:S

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,642
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Java applet error: "Blocked Exception"

    code="javapplettest.JAvAppletTest.class"
    A java class name does NOT end with .class.

    What is the contents of the browser's java console when you load the html file into the browser?

    s it really neccisary to give the .jar file when the browser is only going to use the class files?
    For distribution, it is better to have all the class files in a jar file.
    For testing the class files can be outside of a jar file and you would not use the archive= attribute when testing if the files were not in a jar file.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 2
    Last Post: June 22nd, 2013, 10:30 AM
  2. Replies: 1
    Last Post: April 7th, 2013, 03:40 PM
  3. Replies: 3
    Last Post: December 7th, 2011, 01:03 AM
  4. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM