Applet works in applet viewer but not browser...why?

I won't go into the code, but here's my problem: I work on my applet using Eclipse and its appletviewer, and the applet works fine. I test my applet once in a while by packing all class files and graphics into a jar file, copying it and html file to my desktop and opening the html file. Before, this would work (the applet would get all its info from the jar file), but now... I get a nullpointer exception when I open the browser. If this were to happen in Eclipse, I'd have some way of tracking it. Is there some way of tracking this problem when its seen in a browser?

here's certain key parts of my code... I think this whole "applet not working outside of the project folder" thing started ever since I changed my init() and start() functions so...
     public void init()
          t = new Thread(this);
          t.start();
          addKeyListener(this);
          addMouseListener(this);
          addMouseMotionListener(this);
          sound = new SoundList(); 
     public void start()
          URL resdir;     
          resdir = getClass().getResource("Graphics/Spacebackdrop_01.jpg");
          backgrndImg = new ImageIcon(resdir);
               resdir = getClass().getResource("Graphics/Ship_Blue.gif");
          player1 = new Ship(100, 300, new ImageIcon(resdir), this,
                    gameRect, sound);
          player1.setOrientation(90);
          resdir = getClass().getResource("Graphics/Ship_Green.png");
          player2 = new Ship(700, 300, new ImageIcon(resdir), this,
                    gameRect, sound);
          player2.setOrientation(270);
          resdir = getClass().getResource("Graphics/Ball.gif");
          ball = new Ball(50, 50, new ImageIcon(resdir), this,
                      gameRect, sound);
          initMenus();
          //Initialize the goals
          resdir = getClass().getResource("Graphics/Goalpost.png");
          ImageIcon goalImg = new ImageIcon(resdir);
          goal1 = new Goal(8, gameRect.height/2, 100, goalImg, this);
          goal2 = new Goal(gameRect.width - 8, gameRect.height/2, 100, goalImg, this);
          font = new Font("Verdana", Font.BOLD, 16);
     public void initMenus()
          startMenu = new Menu();
          pauseMenu = new Menu();     
          confirmMenu = new Menu();
          int setY = 200;
          ImageIcon img = new ImageIcon(getClass().getResource("Graphics/newgame.png"));
          ImageIcon imgRoll = new ImageIcon(getClass().getResource("Graphics/newgame_h.png"));
          ImageIcon imgPressed = new ImageIcon(getClass().getResource("Graphics/newgame_p.png"));
          startMenu.addCenteredButton(img, imgRoll, imgPressed, setY, 0, gameRect.width);
          pauseMenu.addCenteredButton(img, imgRoll, imgPressed, setY, 0, gameRect.width);
          setY += 20;
          img = new ImageIcon(getClass().getResource("Graphics/resumegame.png"));
          imgRoll = new ImageIcon(getClass().getResource("Graphics/resumegame_h.png"));
          imgPressed = new ImageIcon(getClass().getResource("Graphics/resumegame_p.png"));
          pauseMenu.addCenteredButton(img, imgRoll, imgPressed, setY, 0, gameRect.width);
          img = new ImageIcon(getClass().getResource("Graphics/Yes.png"));
          imgRoll = new ImageIcon(getClass().getResource("Graphics/Yes_h.png"));
          imgPressed = new ImageIcon(getClass().getResource("Graphics/Yes_p.png"));
          setY += 25;
          int imgWidth = img.getIconWidth();
          confirmMenu.addButton(img, imgRoll, imgPressed, gameRect.width/2 - imgWidth, setY);
          //startMenu.activate(); //make starmenu active.
          img = new ImageIcon(getClass().getResource("Graphics/No.png"));
          imgRoll = new ImageIcon(getClass().getResource("Graphics/No_h.png"));
          imgPressed = new ImageIcon(getClass().getResource("Graphics/No_p.png"));
          confirmMenu.addButton(img, imgRoll, imgPressed, gameRect.width/2 + 2, setY);
     }

Similar Messages

  • Applet running in IDE's applet viewer but not within browser

    Hello,
    I have this applet which runs perfectly on JBuilder4's Applet viewer but when I access the HTML file which JBuilder generated as part of the applet creation the applet won't run.
    The parameters in the applet tag in the HTML file are correct, i.e. the code attribute of this tag has as its value the correct class that implements the applet.
    The only io operations associated with the applet are writing/reading objects to the socket's input/output stream, to communicate with a threaded server which has been started before running the applet. It all runs on the local host. So, I'm not sure it should be signed for it to run in the browser, should it?
    I have tried several browsers, and have the latest java plug-in installed.
    Any comments on this?

    Check this link which might be helpful:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=126261

  • Applet works in applet viewer but not in website.

    I am an experienced programmer, but new to java (second week). I have made working client/server chatroom in java that works when I use the applet viewer, but when trying to run the applet in an html file, I get this error.
    java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.1.3:5136 connect,resolve)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkConnect(Unknown Source)
         at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at java.net.Socket.<init>(Unknown Source)
         at client.Client.init(Client.java:34)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.1.3:5136 connect,resolvI am unsure how to fix this. My first guess is that it is a security issue. Do I need some certificate or something?

    I am trying to connect an applet to a server application run on my computer. The server application is run in the eclipse ide, but I doubt that makes a difference.
    When connecting to the server from the client run through the eclipse ide with the app viewer, everything works fine. When making an html file for the app and running it also on that computer it fails.
    I tried using localhost instead of my internal ip address, and it gave the same errors. I will try signing next, but there must be a way to get this to work without that.

  • Works in applet viewer but not in internet explorer

    I origionaly posted this on devshed. I got 55 views but no replies. It seems to be a common problem to which no one knows the answer. Surprise me :O)I'm sure this is a really common but there seems to be surprisinly litttle on the web about it.
    I developed a game applet a while ago in applet viewer and am now thinking about putting it on my web site. However I have found that it doesn't work in internet explorer. I can browse other sites using Java fine. There is clearly just something about my applet that ie doesn't like.
    Does anyone have any suggestions? What sort of things upset ie?
    All help very much apreciated, you are very nice people
    Flo.

    There must be some thing that tells you it isn't working. You should tell us so we don't have to guess. Does the browser hang? Do you get an error? Did you try opening the Java Console to see if there were any messages? I am guessing that your code is using something that the security level of an Applet does not allow (but appletviewer does allow).

  • Applet works on applet viewer but not in html, why not?

    I'm using Eclipse as a development system and the Eclipse applet viewer shows my applets with no problem. They work the way I expect them to work and all is well.
    When I try to run them in Internet Explorer, I first get a security warning. OK, I trust myself, so I tell Internet Explorer to run the applet. All I get is the text "Hello Dolly", but the applet doesn't run.
    I tried refreshing it, running it again, allowing popups and opening the file, but it just won't run. What could be wrong with something so trivial?
    Any suggestions would be appreciated.
    <html>
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Hello to Everyone</title>
    </head>
    <body>
    <applet CODE="Hello.class" width=300 height=100>Hello Dolly
    </applet>
    </body>
    </html>

    Sorry, I didn't think there was anything special in the applet.
    This just happens to be what I'm checking at the moment.
    It has changed depending upon where in the tutorial I find myself.
    Thanks for you help.
    It has to be something really stupid that I'm missing, but since I'm still new at this game, I can miss something obvious to everyone else.
    package hello;
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.util.Date;
    public class Hello extends Applet implements Runnable {
         private static final long serialVersionUID = 1L;
         Color colors[] = new Color[50];
         Date date1 = null;
         Thread run1 = null;
         Font f1 = new Font("Ariel", Font.PLAIN, 14);
         public void run() {
              int i = 0;
              Thread currThread = Thread.currentThread();
              while (currThread == run1) {
                   setForeground(colors);
                   repaint();
                   i++;
                   if( i>= colors.length) i = 0;
                   try { Thread.sleep(50); }
                   catch (InterruptedException e) {}
         public void init() {
              int i;
              float c = 0.0f;
              for(i=0; i<colors.length; i++) {
                   colors[i] = Color.getHSBColor(c, 1.0f, 1.0f);
                   c += 0.2f;
         public void start() {
              if (run1 == null) {
                   run1 = new Thread(this);
                   run1.start();
         public void stop() {
              run1 = null;
         public void paint(Graphics g){
              date1 = new Date();
              g.setFont(f1);
              g.drawString(date1.toString(), 10, 50);

  • Slideshow works on desktop viewer, but not on iPad

    I have an MSO slideshow that works great on the desktop viewer, but when previewed on the iPad it just shows the first state and doesn't transition to the next state.
    We have made slideshows before that work on both the desktop and iPad content viewer and can't seem to figure out what is causing these not to work. The filename links don't have any special characters or spaces in them. What causes this to happen?

    By any chance, do you link to the MSO from buttons in a scrollable frame? If so, you need to use a different method to convert the MSO to a slideshow. For example, you can select the MSO and choose "Swipe" in the Overlays panel, or you can create an invisible button with a "Go to Next State" action.

  • Edited gif file will work in a viewer, but not in email client

    An animated gif file received in my email client, after editing will not work in the same email client, but is working properly in a browser. Further, the background in the altered gif is black in the email client instead of the non-pixelated file that was "saved for web."
    I had received thsi working gif file and made changes to send the altered animation back, wherin I encountered this quirky littel issue.
    Anyone had this problem or have answers to what's going on here?

    Hi Ozkarleo,
    Please post more information to make your question clear. What’s the type of project you are using? Universal app? Windows phone silverlight app?
    The Sqlite libraries in runtime project are different with those in WinForm. But you have not mentioned what libraries you are using in runtime, so I assume you are using this common ones.
    Sqlite for windows 8.1
    https://visualstudiogallery.msdn.microsoft.com/1d04f82f-2fe9-4727-a2f9-a2db127ddc9a.
    Sqlite for windows phone 8.1
    https://visualstudiogallery.msdn.microsoft.com/5d97faf6-39e3-4048-a0bc-adde2af75d1b.
    One thing important you need note is that we have no access to the entire file system in runtime app, copy the file to local storage then use it.
    A good sample you can get started with it. Get it form MSDN code gallery.
    https://code.msdn.microsoft.com/windowsapps/Using-SQLite-in-a-Windows-c16aea77 .
    If you cannot make it working, please post more information about your scenario.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

  • Custom installed font in iOS7 works in-app view but not in UIWebview or safari.

    I installed a custom font using "configuration profile" (delivering a font payload). Apps successfully used it correctly -- but Safari and UIWebview refuse to use it. Does anyone know how Safari/UIWebview font rendering work?  I cant imagine why it would not work on Safari at all.
    thanks

    I was able to reproduce this with Firefox.  Would you mind opening a new bug on this issue over at bugbase.adobe.com?
    In addition, you might want to repost this question over on the Flash Professional forums?  This forum is primarily for end users, the Pro forums will get you in touch with a wider developer audience.
    Thanks,
    Chris

  • Simple JS works in Acrobat 7, but not 8 - why?

    I have a simple form with 2 fields: "myname" and "phone". "myname" is a drop down list populated with 3 names. I want to be able to populate the "phone" field with a phone number corresponding to the "myname" field automatically.
    I have the following JS attached to the calculate event of the myname field. This works perfect in Acrobat 7.0.9, but does not work at all in Acrobat 8.0 professional or Adobe Reader 8. Does anyone know why?
    switch (myname.rawValue){
    case "Beth Voigt" :
    phone.rawValue = "431-3833";
    break;
    case "Bobbie Hartfiel" :
    phone.rawValue = "431-2019";
    break;
    case "Dave Brown" :
    phone.rawValue = "431-2448";
    break;
    default : phone.rawValue = "";
    event.newText = myname.rawValue;

    I was just asking where those scripts are located.
    You can configure Chrome to use Reader instead of its built-in viewer: http://blogs.adobe.com/vikrant/2010/12/use-adobe-plugins-to-view-pdfs-inside-google-chrome /

  • Embedding video, works on my computers but not theirs, why?

    I have made a flyer that has an embedded video clip using Acrobat Pro 9 Extended.  It opens and plays ok on Professional Extended and Reader on one computer, also opens ok on Professional (non extended) and Reader on another computer.  I emailed the file to my client and he only has Reader.  He tried it on his computer and some other computers with Reader and said he gets an error (see below) which comes up when he opens it and doesnt even show the PDF at all.  He said he upgraded his Readers to the current version and still gets the error.  What else could be causing this?

    it only charge if itunes is installed on the computer
    for some reason

  • JMF works in Applet View, but in web browser, cannot find device

    I'm developing an Applet which can capture image from a web camera.
    It's working very well in the applet view, but it says "No devices" error message through web browser.
    How can I make it work? How can I find device on the web browser?
    I changed permission using "java JMFRegistry", and tried signed Jar.
    Anyone can help me?
    or some of samples would be appreciated...

    Applet view means Applet viewer..

  • My applet works in the appletviewer but not in the navigator

    My applet works in the appletviewer but not in the navigator
    exceptions problem1 and problem2 are throwed
    this is my code
    import java.applet.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ValiderHtml extends Applet implements ActionListener {
    JButton send =new JButton("Connexion");
    JScrollPane jscrollpane= new JScrollPane();
    DefaultListModel lignes=new DefaultListModel();
    JList lstURL = new JList(lignes);
    BufferedReader reader = null;
    String ligne;
    URL url;
    URLConnection conn;
       public void init(){   
       this.setSize(900,400);
       setLayout( new GridLayout(2,1));
       jscrollpane.setBounds(new Rectangle(19,53,160,73));
       jscrollpane.getViewport().add(lstURL,null);
       send.addActionListener(this);
            this.add(send);
       this.add(jscrollpane);
        public void actionPerformed(ActionEvent evt) {
             Send();
       public void Send(){
            try {
       url=new URL("http://www.developpez.com");
       conn = url.openConnection();
       reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    while ((ligne = reader.readLine()) != null) {
                     lignes.addElement(ligne);
        }//fin bloc try
       catch (Exception e) {
                   lignes.addElement("probleme1");     
                finally{
                   try{reader.close();}catch(Exception e){ lignes.addElement("probleme2");}
       }// fin Send
          public void paint(Graphics g) {
                super.paint(g);
    }// fin Applet

    As for tracking the source of your problem your applet sucks.
    Try e.printStackTrace() on a cought exception and check the (full) trace.
    url=new URL("http://www.developpez.com");
    Unless yor applet is on www.developpez.com this will throw an exception in an unsigned
    applet without special policies.
    Signing applets:
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post and last post for the java class file
    http://forum.java.sun.com/thread.jsp?forum=63&thread=409341
    4th post explaining how to set up your own policy with your own keystore

  • Applets work under older compilers, but not newest

    The applets I compile using the latest release of javac (with the JDK 1.4 package) work in the appletviewer but not in IE 6.0. However, if I use an older version of javac from a couple years ago (not sure the version), the applets work in IE suddenly. Is there something I need to install in IE to make it compatible with the Sun 1.4 javac compiler? Should I just reinstall the JRE? Has anyone heard of this before? Thanks!!

    You could try installing the Java 1.4 plugin.
    http://java.sun.com/getjava/

  • Site works in the app, but not in the browser.

    Hello iWeb experts,
    I've got problems.
    Last night I published my site. And while it appears, and functions, properly in my iWeb app, it doesn't do the same in Safari, Firefox, and Internet Explorer.
    Two issues...
    FONTS
    I chose Bellamie, Univers Condensed, and Marydale as my fonts. From reading these forums, I've discovered those won't wysiwyg on other computers if the fonts aren't available and open on them. So my two choices are to make every bit of text a graphic or to use a set of more universal fonts, correct? So my questions are...One, is there a list somewhere of fonts that will work in any browser? And, two, is there a short-cut, or easy way to transform type into a graphic without having to create image files?
    FUNCTIONS
    Here are the functions that work fine in iWeb but have gone haywire in all of the browsers I tested...
    • The type in one nav link appears smaller than all the rest.
    • Some links are active, others are not.
    • Rollover highlighting works on some links, but not others.
    • Most of the rollover links appear in the proper static color, a few do not.
    I've tested these functions on three Macs, one PC, and in the three browsers mentioned above. All of them show the exact same problems. So something must be going wrong with iWebs coding, or my host server musn't like iWeb.
    Any thoughts, suggestions on these two issues? Thanks much for any advice.
    John
    PS - For reference, see: www.johnrunk.com

    Fascinating, Kirk (+he types with one raised eyebrow+).
    QuickTimeKirk wrote:
    When I drag across your page most of your links do not change. The "text" portion of them doesn't change, either. Something is covering them.
    I can see that. But for the life of me, I don't know what could be covering those links. In my app, when I click in the area of the links, the type is the first item selected. Unless, possibly, it could somehow be the faint reflection of my black-and-white image (me & the ground I stand on). Hmmm...
    QuickTimeKirk wrote:
    Single click (outside the boundaries of your page contents) and an "outline" will appear. It shows the image file dimensions and locations.
    This I don't see. An outline? As in "an object outline," or as in "a list of dimensions and locations?" When I click outside my page contents, I get nothing.
    Thanks, QTK. I truly appreciate your troubleshooting here.
    John

  • The scroll function on my mousepad is disabled when viewing a pdf file in firefox version 5.0. The scroll works on the pdf, but not on the other tabs. When the pdf is closed, the scroll function returns to normal. Any ideas?!

    The scroll function on my mousepad is disabled when viewing a pdf file in firefox version 5.0. The scroll works on the pdf, but not on the other tabs. When the pdf is closed, the scroll function returns to normal. Any ideas?!

    Hey thanx for the help, it worked like a charm.
    I think firefox changed the application lay out, as I used to be able to choose my PDF opener from the list at " Adobe Acrobat Forms Document' where I could choose Nitro-PDF reader, but it has now moved all the way to the bottom like you suggested to the obvious place of "Portable Document Format" section.
    If someone didn't tell me , I wouldn't have scrolled all the way down to be able to find it... it really should be with all its cousins up the top...
    Cheers again..

Maybe you are looking for

  • Photo's not showing up inside Events

    When importing photos from my camera memory card, everything goes smoothly. I choose the new event I want to create and the photos import correctly. Although, when I go to the event in the event screen and "double-click" on the event, no photos show

  • Projects Analytics Security

    Hi, Has anyone implement the Project security by using key members? Can you shear about the data security settings

  • Can't upgrade 2010 27" iMac to Yosemite

    Hi all-- i'm at my wits' ends here. I have a 2010 27" iMac with 12GB of RAM. I've been trying to install Yosemite for a week now. (It runs 10.9.5 perfectly.) Whenever I try to upgrade, the iMac restarts and gets to the gray screen with the apple. It

  • MacBook isn't opening PDF files. Not even the ones I created. Help?

    I can't open pdf files. I just get black lines and some clipart. They will open on my PC at work, but not on my mac. I can't even open the ones that i created ON my mac! When I try to open my own files, it says "Convert File From" - any suggestions?

  • Mail opens multiple windows then crashes

    Date/Time: 2006-10-18 18:07:33 -0400 OS Version: 10.3.9 (Build 7W98) Report Version: 2 Command: Mail Path: /Applications/Mail.app/Contents/MacOS/Mail Version: 1.3.11 (622) PID: 526 Thread: 10 Exception: EXCBADACCESS (0x0001) Codes: KERNPROTECTIONFAIL