Applets & Stupid Un-understandable exceptions

here is the problem...
I got test.java, an applet, which I can compile without any problem...(I'm using Sun ONE Studio 4)
but when I try to execute it, it says "Applet not initialized" and the following message appears in the outpout window :
java.lang.ClassCastException
at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:536)
the applet doesn't even go in the init() method
however, if I open test.html, which has the applet on the page, it loads without any problem...
I'd only like to know what this ClassCastException can be related to...

Here's my guess: your class doesn't actually subclass java.applet.Applet. The browser and/or appletviewer instantiates your class and tries to assign it to a variable of type Applet, but since you didn't actually subclass Applet, you get a ClassCastException.
I think the error message "Applet not initialized" refers to the general process of creating an initializing an applet for use, not necessarily to the code in your init() method.

Similar Messages

  • Want to understand Exceptions

    some basic questions regarding exceptions handling:
    * I have some types of exceptions which are not code related but i want to handle them seperately. They include class instantion failure, could not get database connection etc. Their handling in all cases will be same (log it and send to Administrator). I was thinking about creating a seperate exception "InfrastructureFailureException" which will be thrown whenever such errors happens. But I am not sure this is a good idea. The reason is that in a logical-unit-of-work this type of exception can be thrown more than once. That means I have to use more than one try block. For example to get a Connection is a 2 step process:
    try {
    // get Connection Manager
    } catch (InfrastructureFailureException ife) {
    try {
    // get Connection from Connection Manager
    } catch (InfrastructureFailureException ife) {
    Is there any better approach?
    * i have defined a retrieve exception for each domain object, which is thrown by each retrieval operation. So I have a EmployeeNotFoundException which is thrown by getEmployeeById(int employeeId) DAO method. Similarly I have a DepartmenNotFoundException which is thrown by getDepartmentById(int deptId) DAO method.
    Now I am thinking the above exceptions can be grouped as they belong to retrieve. So create a RetrieveFailedException and use it as a parent of the above exceptions. Is it a good idea?
    I am also thinking about applying the same logic for INSERT and UPDATE (InsertFailedException and UpdateFailedException will be used as parents)
    * Suppose an exception is thrown. I am having problems deciding which method to let handle this exception in the call stack.
    Thanks

    >>
    However, for those who do develop applications,you
    will either use a library (in which case it willbe
    exceptionally relevant, pardon the pun). Or youwill
    develop your own exceptions. Often I develop one for large applications.
    Sometimes I develop one or two for a single layer.
    Never more.
    A library that does that is probably doing something
    wrong.
    An application that developes many is probably doing
    something wrong as well. In my experience, that
    happens because the developers are applying the
    standards of library developement to application
    developement.
    Libraries are developed to serve the needs of
    different users and with the intent that they will be
    definitely be used in ways that the library
    developers did not anticipate. Application are
    developed to meet very specific guidelines. The
    goals of both are different. Thus the goals and
    functionality of each are different.
    I agree. However, I make a distinction (see below) in types of exceptions. What the OP referred to are what I implement as 'unchecked' exceptions. These also seem to comport with your conception of an exception: that they
    are truly exceptional. Truly exceptional circumstances are generally not recoverable. The unchecked data access framework of Spring is an excellent example of this. As these resembled the OP's original needs, I pointed out that library. In an actual application, I would use the library, customizing these exceptions to my own needs, or simply catching them in a front controller to display an error message to the user.
    In either case, seeing
    how an established library was constructed should
    give you ideas on how your own exceptions might be
    classified. I doubt it. Unless you are a library developer.
    See above.
    Data access exceptions are data access
    exceptions. You may not need something asfull-blown
    as Spring's data access exceptions, butundoubtedly
    you will use at least a few.Yes - a few.
    That having been said, in real applications, the
    majority of important exceptions will be your
    checked, business/model exceptions. Concentrateyour
    efforts there. Worrying about whether I shoulduse
    java.io.IOException or
    com.foo.exception.NetworkException will distractyou
    from the exceptions you actually need to write.In real applications, at least the ones that I have
    worked on, exceptions are exactly that exceptions.
    They are not anticipated, they are not expected and
    d in normal operations they should never occur. They
    do not need to be classified because any such
    classification would suggest that they are
    correctable when in reality, because they are
    exceptions, they are not.
    The customer help desk doesn't care whether the
    database is down, or if there is a duplicate
    insertion error, nor that the type specifier
    definition is missing in a table. All of them means
    that the customer service person can not do their job
    and all mean that they have to call someone else who
    will have to fix it. And to the person that fixes it
    seperate exceptions will have gain no benifit if
    there are multiple exceptions or one.
    Exactly. This is why they are unchecked and intercepted only at a front controller level to display a generic error page to the user, and potentially issue a page for support or entry into a log file.
    Additionally application developers often,
    incorrectly, use exception hierarchies in such a way
    that it completely destroys the information needed to
    actually fix the problem in the first place, because
    they end up throwing away the original exception
    because they found a "better" one to return.However, I disagree with your notion of 'exceptional' exceptions. This is not in any way to say my way is 'correct', but rather to simply explain it.
    Any time I read a business requirement that has an abnormal path of exceution (balance below zero, user account not found, accessing the flux capacitor on an even-numbered day of the month, etc.), I create a checked, business exception for that use case. It has an English-readable name, and any business user would be able to understand what that exception is for.
    When developing the application, these exceptions ensure that all expected business exceptions are accounted for. It also reminds me of what abnormal paths of execution the business users have specified. Any business service should handle the possible business exceptions involved in a given call.
    The remainder of exceptions are 'exceptional' exceptions. These I leave as unchecked. Sometimes I use a library or framework ala Spring, especially for data access or XML parsing or other general failure possibilities. Other times, when none are available, I create my own. However, they are always unchecked.
    - Saish

  • System.out.println(...) causes applet to throw OutOfMemoryError exception

    Hi all,
    I've created an applet with a very barebones method in it, that is causing an OutOfMemoryError when run for approx 2 minutes.
    Here is the code...
    import javax.swing.JApplet;
    public class BridgeMapApplet extends JApplet
    public void start()
              Thread t = new Thread(){
              public void run() {
                   String response = "<bridgeMapResponse><bridges><bridge><macAddress>00:07:D5:01:3B:ED</macAddress><parentMacAddress>00:00:00:00:00:00</parentMacAddress><ipAddress>192.168.254.157</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>0</rssi><stpStatus></stpStatus><children><bridge><macAddress>00:07:D5:01:3C:19</macAddress><parentMacAddress>00:07:D5:01:3B:ED</parentMacAddress><ipAddress>192.168.254.166</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>73</rssi><stpStatus></stpStatus><children><bridge><macAddress>00:07:D5:01:45:BE</macAddress><parentMacAddress>00:07:D5:01:3C:19</parentMacAddress><ipAddress>192.168.254.152</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>80</rssi><stpStatus></stpStatus><children><bridge><macAddress>00:07:D5:01:47:12</macAddress><parentMacAddress>00:07:D5:01:45:BE</parentMacAddress><ipAddress>192.168.254.153</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>0</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge><bridge><macAddress>00:07:D5:01:46:78</macAddress><parentMacAddress>00:07:D5:01:45:BE</parentMacAddress><ipAddress>192.168.254.162</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>0</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge><bridge><macAddress>00:07:D5:01:3D:B9</macAddress><parentMacAddress>00:07:D5:01:45:BE</parentMacAddress><ipAddress>192.168.254.154</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>0</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge></children><description></description><deviceStatus>New</deviceStatus></bridge></children><description></description><deviceStatus>New</deviceStatus></bridge><bridge><macAddress>00:07:D5:01:46:94</macAddress><parentMacAddress>00:07:D5:01:3B:ED</parentMacAddress><ipAddress>192.168.254.165</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>63</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge><bridge><macAddress>00:07:D5:01:3D:D3</macAddress><parentMacAddress>00:07:D5:01:3B:ED</parentMacAddress>ipAddress>192.168.254.168</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>78</rssi><stpStatus></stpStatus><children><bridge><macAddress>00:07:D5:01:46:7A</macAddress><parentMacAddress>00:07:D5:01:3D:D3</parentMacAddress><ipAddress>192.168.254.163</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>100</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge><bridge><macAddress>00:07:D5:01:3D:D5</macAddress><parentMacAddress>00:07:D5:01:3D:D3</parentMacAddress><ipAddress>192.168.254.161</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>99</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge><bridge><macAddress>00:07:D5:01:3D:6F</macAddress><parentMacAddress>00:07:D5:01:3D:D3</parentMacAddress><ipAddress>192.168.254.164</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>100</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge><bridge><macAddress>00:07:D5:01:3D:81</macAddress><parentMacAddress>00:07:D5:01:3D:D3</parentMacAddress><ipAddress>192.168.254.167</ipAddress><card></card><secondCard></secondCard><wdsName></wdsName><cfgFileTag></cfgFileTag><rssi>100</rssi><stpStatus></stpStatus><description></description><deviceStatus>New</deviceStatus></bridge></children><description></description><deviceStatus>New</deviceStatus></bridge></children><description></description><deviceStatus>New</deviceStatus></bridge></bridges><lastUpdate>2009-12-21T19:45:25.375Z</lastUpdate></bridgeMapResponse>";
    while(true) {
                        System.out.println(response);
                        try{
                             Thread.sleep(10);
                        }catch(InterruptedException ie){}
                   } //end while
              } //end run
              }; //end thread
              t.start();
    } // end of start()
    } // end of applet
    When I connect to the process with a java debugger, i get the following output after a couple minutes...
    C:\eclipse\workspace\applet>jdb -attach 2502
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    Initializing jdb ...
    >
    Exception occurred: java.lang.OutOfMemoryError (uncaught)"thread=traceMsgQueueTh
    read", com.sun.deploy.util.Trace.firePrintlnEvent(), line=-1 bci=58
    traceMsgQueueThread[1]
    ===================================================================
    I know this is a very frequent thread execution, but this was to speed up the replication of a bug that occurs after a few hours.
    Regardless of how low the Thread.sleep() interval is, why would this cause an OutOfMemoryError?
    thank you!!

    When posting code, code snippets, HTML/XML or input/output, please use the code tags. The code tags help retain the indentation and formatting of the sample. To use the code tags, select the sample and click the CODE button.
    As an aside, what on earth is the use of dumping output to the console in an applet?
    My initial thought as to how prevent the OOME when dumping loads to the Java Console is - don't dump loads to it. The Java Console is effectively useless to the average end-user, either way. The Java Console is not easy to open, for an applet that makes it through the init() successfully.

  • Self signed Applet - still getting Security Exception...

    Hi everyone...
    I m new to Java Mail... Nd I m developing a Applet to send mail from my Gmail account, nd I used keytool, jarsigner to Self sign the applet. Nd I wrote a Html page and when calling my applet method using javascript, I m having Security Exception... And I m using Java 1.5 (i.e., J2SE 5)
    Here is the sample of my code...
    --------- MyMail.java -----------
    import javax.mail.*;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    And all neccessory packages are imported....
    public class MyMail extends JApplet
         String server = "smtp.gmail.com";
         String username;
         String password;
         String fromAddres="";
         String toAddres="";
         Other Variable declaration goes here........
    Session ses;
    Transport tr;
    MimeMessage msg;
         public void init() //For testing purpose
              doLogin("username","password"); //My account details
         public void doLogin(String user,String pass)
              username = user;
              password = pass;
              boolean success;
              fromAddres = user+"@gmail.com";
              toAddres = "[email protected]";
              subject = "TEst SubJect";
              body = "This is Test Mail";
              success = doAuthentication();
              if(success)
                   setHeaders(server,username,password,fromAddres,toAddres,cc,bcc,htmlFormat,subject,body);
                   sendMail(ses);
                   doLogout();
         public void doLogout()
              //Deals with the logout from my account
         public boolean doAuthentication()
              //Deals with the authentication of my account
              // Setting properties, creating a session, getting transport object...
              //and returns true if authentication is success, false if not.
         public void setHeaders(String server, String username, String password, String fromAddress, String toAddress, String cc, String bcc, boolean htmlFormat, String subject, String body)
              //Sets the headers fields for the message (recieved through arguments)
         public void sendMail(Session ses)
              //Deals with sending mail
    class MyPasswordAuthenticator extends Authenticator
         //Deals with the authentication of my account
    ---------- MyMail.html -----------
    <html>
    <head>
    <script language=javascript>
    function sendmail()
    document.MyMail.doLogin("username","password"); //my account details
    </script>
    </head>
    <body>
    <input type=button name=but value=Send mail onclick=sendmail()>
    <applet name=MyMail code=MyMail.class
    archive=mail.jar,activation.jar,mailplus.jar width=0 height=0>
    </applet>
    </body>
    </html>
    And the applet is Self signed using the tools supplied from Java SDK...
    it got signed...
    And as the applet got loaded when i opend the MyMail.html, as i called the doLogin(..,..) in init() it is sending mail successfully...
    The problem is.... As I given the action for my button to send mail (by calling java method from java script i.e., calling doLogin() when the button clicked) I m getting Security Exception
    So...anyone plz tell me the solution....
    Thnx in advance....
    - Kanta

    http://www.google.nl/search?hl=nl&q=site%3Asun.com+javascript+signed+applet&btnG=Google+zoeken&meta=
    DoPrivileged would solve your problem but I've seen some cases where the
    threaded (link mentioned below second post) mothod is the only way it'll work.
    Signing applets:
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post and reply 18 for the java class file using doprivileged
    Still problems?
    A Full trace might help us out:
    http://forum.java.sun.com/thread.jspa?threadID=656028

  • Applet is null - security exception in servlet

    I have searched this forum and others in trying to resolve this issue with no luck. I just upgraded my servlet app to use the 9.0.1.4 JDBC drivers (by downloading the classes12.zip) from a previous version in Websphere Application Developer 5.1. I used the same connection string as in the older Oracle JDBC drivers (which worked) and keep getting the messages "Applet is null, cannot report" and "Exception: java.lang.SecurityException: not allowed to connect to server". I think the applet error is that the error handling in the JDBC drivers is trying to launch an applet, but I am not sure why I am getting the security error. Has anyone experienced this?

    You may need to make changes in your JDK's java.policy file. It is expecting 'checkPermission with the PropertyPermission("*", "read,write") permission.'
    Try by adding,
    permission java.util.PropertyPermission "*", "read,write";
    to your java.policy file.
    Sudha

  • How to create thread in applet without causing modifyThreadGroup exception?

    I've searched through this forum, and it has dozens of posts regarding infamous modifyThreadGroup exception. The two answers I continuously stumble upon are:
    1) Change something in permission file. This is unacceptable, because I'm writing an applet, which by definition should be portable.
    2) Sign the jar file. This is still unacceptable, because a) I do not know how to do this yet b) from what I've seen, process of signing is quite complicated c) I'm still in the development stage, using NetBeans 4.0, so I can't use jar's d) I just need to instantiate a freakin' thread, that's all.
    Now, instead of searching for quick fix, I want to ask couple of meaningful questions.
    1) Why some security managers do not allow me to instantiate new threads in applet? Why other security managers do? (Write once, run everywhere. Yeah, right.)
    2)How can I create thread in applet, maintaining applet's portability?
    PS: Sorry for the attitude. The case is, such things in Java irritate me greatly.

    what are you trying to do within these ThreadsMy applet needs to dynamically receive and display data from a server (also written in Java). Data changes over time, so applet needs to render this changes.
    The problem is not with the content of the thread (for there is no content yet), but with the fact that tread created at all. Here is the code that generate named exception:
            Thread receivingThread = new Thread() {
                public void run(){
                    //do something
    [quote]
    As you can see, I'm not even running a thread, but merely creating it. (Well, I will need to run it anyway, but it's the instantiation that causes problem currently.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java applet class not found exception for check scan

    I am getting a class not found exception when trying to scan a check into a banking website. The application uses Java and the exception error has the name "com.epaysol.checkscanAppletV2" in the message. I have the latest Firefox and the latest Java installed. I tried going to an earlier version of Firefox and of Java where this app worked in the past and it does not work now in the earlier versions either. So I am now back to the latest version of everything.

    Try to clear the Java cache:
    * http://www.java.com/en/download/help/5000020300.xml
    Control Panel > Java > General tab > "Temporary Internet Files" > Settings > Delete Files
    *XP: C:\Documents and Settings\<user>\Application Data\Sun\Java\Deployment\cache\
    *Vista: C:\Users\<user>\AppData\LocalLow\Sun\Java\Deployment\cache\

  • Un-understandable exception

    Hi, I am getting the following error when requesting a .jsp:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: com.eclinck.web.UserBean.setContactNumber(Ljava/lang/String)V
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
    I can find absolutely no reason for this problem. Here is my code (first the .jsp segment)
    statement = connection.getConnection().createStatement();
    result = statement.executeQuery(sql);
    if (result.next()) {
    System.out.println("User Found in db");
    user.setUserName(result.getString("username"));
    user.setEmail(result.getString("email"));
    user.setPassword(result.getString("password"));
    user.setCompanyName(result.getString("name"));
    user.setContactNumber(result.getString("contact_number"));
    user.setID(result.getString("token_owner_id"));
    user.setCountry(result.getString("country"));
    user.setAddress(result.getString("address"));
    user.setCity(result.getString("city"));
    user.setState(result.getString("state"));
    user.setZip(result.getString("zip"));
    user.setLogged(true);
    response.sendRedirect("profile.jsp");
    } It is only at the setContactNumber() method, and any method thereafter that the error occurs. The bean code is right, with all the methods set(x) accepting String parameters. Even when I hard code string (instead of retrieving from db) I still get the same error on any method except the first four.
    any help would be appreciated
    thx
    brenda

    Sorry, the rest of the post is:
    It is only at the setContactNumber() method, and any method thereafter that the error occurs. The bean code is right, with all the methods set(x) accepting String parameters. Even when I hard code string (instead of retrieving from db) I still get the same error on any method except the first four.
    here is the bean code:
    public void setUserName(String tempName) {
            this.userName = tempName;
        public void setEmail(String tempEmail) {
            this.email = tempEmail;
        public void setCompanyName(String tempCompany) {
            this.companyName = tempCompany;
        public void setPassword(String tempPassword) {
            this.password = tempPassword;
        public void setCountry(String tempCountry) {
            this.country = tempCountry;
        public void setContactNumber(String tempNumber) {
            this.contactNumber = tempNumber;
        public void setID(String tempID) {
           this.ID = tempID;
        public void setCity(String city) {
           this.city = city;
        public void setState(String state) {
           this.state = state;
        public void setZip(String zip) {
           this.zip = zip;
         public void setAddress(String address) {
           this.address = address;
        public void setLogged(boolean tempLogged) {
           this.logged = tempLogged;
        all the variable (except boolean tempLogged) are declared private String...
    Any help ?
    thx
    brenda

  • Applet loading fails: ClassNotFound exception onlyyyy on linux

    Hello,
    I have a server on my embedded device with WinCE, and this server has the jar files and html files. connecting with Windows is working fine and Java applet loads and runs perfectlly.
    The problem is with linux clients, I can't load the applet.
    I expected to havesomething wrong with the plugin, But I tried with the test applets on www.sun.com and they are working fine.
    The error is ClassNotFoundException and http connection failed, although when I take the URL copy/paste from the Java console to the address bar of the firefox it downloads the class file. so the path is OK.
    Also I can run with the appletviewer and it works perfect like the case with windows. The problem is with the browser, It can'T load the applet from a remote machine.
    Also I made an empty applet with a button on it to check may be I should compile on linux!! but also this failed, I could load this applet locally (the html and class files on desktop) and when I places them on the server in the directory configured to be the www public directory It is not loaded. And again this test applet laoded on windows machines.
    I use the same JRE version on linux and windows and the same JDK.
    I use on windows Opera/ Firefox/ explorer and all are working, on linux I use Firefox/ Konqurer/ Epiphany and all are not working.
    Any Idea?????
    Thanks in Advance

    Hello,
    I have a server on my embedded device with WinCE, and this server has the jar files and html files. connecting with Windows is working fine and Java applet loads and runs perfectlly.
    The problem is with linux clients, I can't load the applet.
    I expected to havesomething wrong with the plugin, But I tried with the test applets on www.sun.com and they are working fine.
    The error is ClassNotFoundException and http connection failed, although when I take the URL copy/paste from the Java console to the address bar of the firefox it downloads the class file. so the path is OK.
    Also I can run with the appletviewer and it works perfect like the case with windows. The problem is with the browser, It can'T load the applet from a remote machine.
    Also I made an empty applet with a button on it to check may be I should compile on linux!! but also this failed, I could load this applet locally (the html and class files on desktop) and when I places them on the server in the directory configured to be the www public directory It is not loaded. And again this test applet laoded on windows machines.
    I use the same JRE version on linux and windows and the same JDK.
    I use on windows Opera/ Firefox/ explorer and all are working, on linux I use Firefox/ Konqurer/ Epiphany and all are not working.
    Any Idea?????
    Thanks in Advance

  • Understanding Exception handler activity

    All,
    I created 2 view activities in my adfc-config.xml and established a navigation flow between them. The flow happens on click of a button on view1. I have defined an exception handler activity to show unhanded error that may arise. On click of the button in the view1, AM IMPL methods gets called and this is the code
        public void newPage(){
            int k = 5/0; //expecting the error handler activity to get invoked here   
        } When i click on the button, i get the exception however the page associated with exception handler is not getting invoked. I want the exception handler page to be shown for error and not the default popups. How do we do that?
    thnks
    Jdev 11.1.1.5

    No, this is only one possibility...
    checkout Andrejus blog about exception handling http://andrejusb-samples.blogspot.com/2011/03/jdevadf-sample-exception-handler-for_19.html and of cause the docs http://download.oracle.com/docs/cd/E24382_01/web.1112/e16182/taskflows_complex.htm#BACJCBIC
    Timo

  • Java.io.File causes "access denied" exception in a signed applet

    Hi,
    New to these forums and not entirely where it's appropriate to post this issue, so I'll stick it here for now until told otherwise.
    The problem:
    My applet throws the following exception.
    INFO: Exception Message: access denied (java.io.FilePermission C:\Some Dir With Spaces\AnotherDir\FinalDir read)
    The psuedo-code:
    java.io.File RootPath = new java.io.File( "C:\" );
    private boolean doesSubdirectoryExist(String directory) {
            boolean mResult = false;
            try
                java.io.File tmpPath = new java.io.File( RootPath.toString() + java.io.File.separatorChar + directory );
                mResult = tmpPath.isDirectory();
                tmpPath = null;
            catch (Exception e)
                ... error handling code
            return mResult;
    private void btnCheckPathActionPerformed(java.awt.event.ActionEvent evt) {
            ....some other stuff....
            doesSubdirectoryExist(.. a text field value from the GUI form..);
            ....some other stuff....
    }                                       The conditions:
    1) The applet is signed.
    2) The applet runs fine in the AppletViewer.
    3) I am using JDK1.5.0_09.
    4) When I click the button the event handler is tied to, it works correctly the first time.
    5) If I click a second time, with the same value in the text field (i.e. testing for the same subdirectory again) I get the exception error.
    I'm pulling my hair out trying to figure this one out. If it were a security issue with the applet running from a browser, why does it work the first time?
    Am I failing to release some lock that creating a java.io.File instance creates?
    I would appreciate any help.

    I've identified the issue. I was attempting to access the filesystem from two different thread and/or contexts.
    It seems that if I use the SwingWorker class from https://swingworker.dev.java.net/ to perform background tasks in the Worker thread, I don't get the security privileges required to modify the filesystem. Even though I have signed the jar correctly.
    However I can access the filesystem quite happily from the Event Dispatcher thread. If my jar is signed correctly.
    So, I have the following questions:
    1. Why doesn't SwingWorker worker threads get the same security context as the event dispatcher thread?
    2. Is there anyway I can give the worker thread the necessary security privileges?
    3. Is there anyway to do this without having to write my own thread handling code and creating my own thread pools?
    Message was edited by:
    Fidotas
    Message was edited by:
    Fidotas

  • EOF exception during applet - servlet communication

    I am developing a system for the US Gov't. This system currently
              utilizes several applets which access corresponding servlets on
              WebLogic. Seemingly, things went wrong for no apparent reason this
              morning. When, trying to run our applets, WebLogic throws an exception:
              "Caught EOFException in the stream header" These exceptions occur
              everytime the servlet would open the input stream from the applet. What
              makes things mind-boggling is that these applets/servlets were working
              this morning, and suddenly now give these exceptions. The code for both
              the applets and servlets has not been touched in weeks. Furthermore, i
              tested even further by running WebLogic locally and running the applets
              in our IDE (as applications) and the same results occur. I am running
              WebLogic 5.1 SP6 on both the remote and local system and am utilizing
              JDK 1.3 on both as well. The server is running on WinNT SP6 and locally
              is Win2000 Pro SP1. These applets are critical to the entire system and
              i am just totally baffled as to why something that was working fine one
              day ago should all of the sudden spit up errors and exceptions.
              If anyone can give me some insight as to what is going on, please let me
              know.
              Thank you,
              Randy Strobel
              [email protected]
              

    Randy,
              I don't know of any particular reasons why WebLogic would suddenly affect an
              application in the manner that you describe. Start by figuring out where
              the message comes from:
              > "Caught EOFException in the stream header"
              I assume that is in WebLogic's code, not yours? Figure out as close as
              possible who is detecting this error condition. If it is in WebLogic's
              code, you can ask support at BEA to tell you what it is complaining about
              (i.e. what it is expecting to read).
              You will have to post the exception trace here and it would help to see the
              code that is causing the exception.
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Randy Strobel" <[email protected]> wrote in message
              news:[email protected]...
              > I am developing a system for the US Gov't. This system currently
              > utilizes several applets which access corresponding servlets on
              > WebLogic. Seemingly, things went wrong for no apparent reason this
              > morning. When, trying to run our applets, WebLogic throws an exception:
              > "Caught EOFException in the stream header" These exceptions occur
              > everytime the servlet would open the input stream from the applet. What
              > makes things mind-boggling is that these applets/servlets were working
              > this morning, and suddenly now give these exceptions. The code for both
              > the applets and servlets has not been touched in weeks. Furthermore, i
              > tested even further by running WebLogic locally and running the applets
              > in our IDE (as applications) and the same results occur. I am running
              > WebLogic 5.1 SP6 on both the remote and local system and am utilizing
              > JDK 1.3 on both as well. The server is running on WinNT SP6 and locally
              > is Win2000 Pro SP1. These applets are critical to the entire system and
              > i am just totally baffled as to why something that was working fine one
              > day ago should all of the sudden spit up errors and exceptions.
              >
              > If anyone can give me some insight as to what is going on, please let me
              > know.
              > Thank you,
              > Randy Strobel
              > [email protected]
              >
              >
              

  • XML Parsing Error in applet

    I'm trying to parse a XML dicument in an applet with the following code
    String url = "myfile.xml";
    org.w3c.dom.Document doc = null;
    try
    doc = db.parse(url);
    catch (SAXException se)
    System.out.println("SAX error");
    and get the SAXException when the XML document contains a
    non-ASCII, but ISO-8859-1 character (i.e. '�' = 0xE4)
    Running the same code as Java application on the same computer,
    where I also run the applet, works fine (no exception occurs).
    IMHO, there should not be any difference, both applet and application
    should use the same VM and, hence, the same XML parser.
    Any idea why not?
    I have the Sun VM coming with JRE1.4.0 installed on a PC with
    windows 2000, and also got the same result with JRE1.4.2.
    I checked whether the server application sends the correct xml document
    by printing it to System.out (=java console of the browser, where the applet
    runs, and this seems to be OK. So, my java application seems to be OK.
    Is there any possibility that some settings in the browser cause this problem?
    The longer I think about it, the more I'm confused.
    Thanks in advance for any suggestions!

    the error was set I didn't set the contentLength in the http header when sending the xml file from the servlet.
    I don't really understand why this caused the type of error I experienced, but, at least, my applet works fine now.

  • JXL -- Applet -- NoClassDefFoundError

    First off, I have no clue if this is the correct place to post this, and I'm sorry if it isnt but I couldnt find a forum more specific.
    I am building a project that will be an applet and ran from my school's web server. The program will work similarly to how freerice.com does their thing, only it will include latin vocabulary and there is no free rice for the poor.
    In order to hold all of the vocab words/user data I have decided to use an excel sheet. This is because the data has already been created and it is in an excel sheet, so its just easier that way. So since I will be using an excel sheet for my databasing, I found jxl to be a potentially useful tool.
    I ran a test/learning program to figure out how jxl works, the possible issues I would run into, ect. THAT program was an application. So after getting to a place where I feel comfortable with jxl, I decided to make the necessary changes to my applet to include jxl. However I had some issues which I will talk about below. Here is the code and output for each program.
    Test/Learning Application Code:
    //Imports
    import java.io.File;
    import java.util.Date;
    import jxl.*;
    import jxl.write.*;
    import java.io.*;
    public class Excel
        //Main
        public static void main(String[] args) throws Exception
             //Read
             //Get workbook
             Workbook workbook = Workbook.getWorkbook(new File("myfile.xls"));
             //Get sheet
             Sheet sheet = workbook.getSheet(0);
             //Get Cells
             Cell a1 = sheet.getCell(0,0);
              Cell b2 = sheet.getCell(1,1);
              Cell c2 = sheet.getCell(2,1);
              //Get cell content
              String stringa1 = a1.getContents();
              String stringb2 = b2.getContents();
              String stringc2 = c2.getContents();
              //Print out cell content
              System.out.println(stringa1);
              System.out.println(stringb2);
              System.out.println(stringc2);
              //Close workbook
             workbook.close();
             //Write
             //Get workbook
             Workbook workbook2 = Workbook.getWorkbook(new File("myfile.xls"));
             //Create copy
             WritableWorkbook copy = Workbook.createWorkbook(new File("myfile.xls"), workbook2);
             //Get sheet to be written to
             WritableSheet sheet2 = copy.getSheet(0);
             //Get cell to be written to
              WritableCell cell = sheet2.getWritableCell(1, 2);
              //Write
              if (cell.getType() == CellType.LABEL)
                     Label l = (Label) cell;
                     l.setString("modified cell");
              //Write and Close workbook
              copy.write();
              copy.close();
              //Read again to check for changes
              workbook = Workbook.getWorkbook(new File("myfile.xls"));
             sheet = workbook.getSheet(0);
             a1 = sheet.getCell(0,0);
              b2 = sheet.getCell(1,1);
              c2 = sheet.getCell(2,1);
              stringa1 = a1.getContents();
              stringb2 = b2.getContents();
              stringc2 = c2.getContents();      
              System.out.println(stringa1);
              System.out.println(stringb2);
              System.out.println(stringc2);
             workbook.close();
    }Output:
    (0,0)
    (1,1)
    (2,1)
    (0,0)
    (1,1)
    (2,1)That is exactly what I wanted to get, so there are no issues here.
    Applet Code (edited for space and importance):
    //Imports
    import jxl.*;
    import jxl.write.*;
    import java.io.File;
    import java.io.*;
    public class Host
         ArrayList<User> userArr = new ArrayList<User>();
         JApplet app;
        public Host(JApplet j)
             app = j;
             readUsers();
             for(int i=0;i<userArr.size();i++)
                  User user = userArr.get(i);
                  System.out.println(user.getName()+" "+user.getPassword()+" "+user.getLevel()+" "+user.getPoints());
        //Method having trouble
        public void readUsers()
             try
                    //Runtime Error Occurring here
                  Workbook workbook = Workbook.getWorkbook(new File("data.xls"));
                  Sheet sheet = workbook.getSheet(1);
                  for(int i=0;i<sheet.getRows();i++)
                       Cell nameC = sheet.getCell(i,0);
                       Cell passC = sheet.getCell(i,1);
                       Cell lvlC = sheet.getCell(i,2);
                       Cell ptsC = sheet.getCell(i,3);
                       String name = nameC.getContents();
                       String password = passC.getContents();
                       int level = Integer.parseInt(lvlC.getContents());
                       int points = Integer.parseInt(ptsC.getContents());
                       userArr.add(new User(name,password,level,points));
                  workbook.close();
             catch(Exception e)
                  System.out.println(e);
    }Output (RUNTIME error):
    java.lang.NoClassDefFoundError: jxl/Workbook
        at Host.readUsers(Host.java:47)
        at Host.<init>(Host.java:35)
        at Vocab.init(Vocab.java:26)
        at sun.applet.AppletPanel.run(AppletPanel.java:424)
        at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: jxl.Workbook
        at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:210)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:143)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 5 moreSo I'm not sure why this is happening here. The only significant difference between the two projects is that one is an application and the other is an applet.
    I understand what the error is saying, but I cant seem to find out how to fix it. I just wanted to provide as much information as possible in hope for better solutions. Any help is greatly appreciated.

    Aussiemcgr wrote:
    Ok, well just for clarification, it is possible to have the library and excel file on the server correct? I seriously doubt it. I would expect that the library you are using requires access to a file. The applet runs on the client thus the file system that the library will use will be that of the client.
    So at some point the excel file will need to be on the client. Alternatives to this
    1. The library supports a stream rather than a file. Then you would need to write quite a bit of code to create a stream that loads the data across the network.
    2. The client OS has a mapped drive with the server. This is an OS feature not a java feature. It is also unsecure on the internet so only suitable, at best, on a private network.
    This is because the excel file will be both written to and read from by each user. I think you need to start over from the architecture and design point of view.
    Consider this what exactly happens in an excel file when two users try to write to it at the same time. This is NOT a java question.
    I already told you that the easiest way to do is to have a copy of the file on the client machine. Your requirement above completely rules this out. The only possible solution using only an applet requires a mapped drive. And that has the previously mentioned limitations. And even then you are going to need a design that deals with that.
    A better solution
    1. Use an actual java server, not just an applet.
    2. Move the data into a real database.

  • IndexOutOfBounds Exception using ArrayList running in a Thread

    Hi, I am a beginner in Java. While I am studying I became interested in Game Developing. So I tried to create a game like Space Shooting. Although the design and the ship lives are not yet finished it should run. Here is my whole code.
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.awt.*;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import java.io.File;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.ArrayList;
    import java.util.Random;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    class Ship
        int x,y,lives;
        long score,lastExplodeDisplay;
        public Ship()
            x = 307;
            y = 444;
            lives = 3;
            score = lastExplodeDisplay = 0;
        public void move(int xDir)
            x = x + xDir;
    class Asteroid
        int x,y,speed;
        Random asteroidGenerator;
        int explodeMode;
        long lastExplodeDisplay;
        public Asteroid()
            asteroidGenerator = new Random();
            x = asteroidGenerator.nextInt(600) + 10;
            y = asteroidGenerator.nextInt(1250) + 100;
            y = y * -1;
            speed =  1;
            explodeMode = 0;
            lastExplodeDisplay = 0;
    class Star
        int x,y,speed,radius,colorChooser;
        Color color;
        Random starGenerator;
        public Star()
            starGenerator = new Random();
            x = (starGenerator.nextInt(620) + 10);
            y = (starGenerator.nextInt(460) + 10);
            speed = starGenerator.nextInt(2) + 1;
            radius = (starGenerator.nextInt(3));
            colorChooser = starGenerator.nextInt(200);
            if(colorChooser % 3 == 0)
                color = Color.YELLOW;
            else if(colorChooser % 4 == 0)
                color = Color.BLUE;
            else if(colorChooser % 5 == 0)
                color = Color.RED;
            else
                color = Color.WHITE;
    class Shot
        int x,y,speed;
        public Shot(int position)
            x = position + 3;
            y = 440;
            speed = 7;
    public class Main extends JFrame implements Runnable{
        private Image dbImage, ship,shot,asteroid,explode,shield;
        private Graphics dbg;
        private ImageIcon i;
        private Font stageFont;
        long lastShot, start;
        AudioClip shoot;
        String scoreShow;
        int lastAsteroidPosition;
        Ship ship1 = new Ship();
        Star[] stars = new Star[200];
        ArrayList<Shot> shots = new ArrayList<Shot>();
        ArrayList<Asteroid> asteroids = new ArrayList<Asteroid>();
        ArrayList<Asteroid> exploded = new ArrayList<Asteroid>();
        boolean[] keys = new boolean[3];
        private boolean shipDestroyed,continued,shielded;
        private int ex;
        public class ActionList extends KeyAdapter{
            public void keyPressed(KeyEvent e)
                int keyCode = e.getKeyCode();
                if(keyCode == e.VK_A)
                    keys[0] = true;
                if(keyCode == e.VK_D)
                    keys[1] = true;
                if(keyCode == e.VK_Y)
                    keys[2] = true;
                if(keyCode == e.VK_F2 && !continued)
                    continued = true;
                    shipDestroyed = false;
                    ex = 0;
                    shielded = true;
                    start = System.currentTimeMillis();
                /*if(keyCode == e.VK_A)
                    if(ship1.x <= 15)
                        ship1.x = 15;
                    else
                        ship1.x -= 5;
                if(keyCode == e.VK_D)
                    if(ship1.x >= 589)
                        ship1.x = 589;
                    else
                        ship1.x += 5;
                if(keyCode == e.VK_Y)
                    Shot newShot = new Shot(ship1.x);
                    shots.add(newShot);
            public void keyReleased(KeyEvent e)
                int keyCode = e.getKeyCode();
                if(keyCode == e.VK_A)
                    keys[0] = false;
                if(keyCode == e.VK_D)
                    keys[1] = false;
                if(keyCode == e.VK_Y)
                    keys[2] = false;
        public Main()
            createStars();
            addKeyListener(new ActionList());
            setSize(640,480);
            setTitle("Shoot by Takeshi®");
            setResizable(false);
            setVisible(true);
            setBackground(Color.BLACK);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/ship1.png");
            ship = i.getImage();
            i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/shot.png");
            shot = i.getImage();
            i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/asteroid.png");
            asteroid = i.getImage();
            i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/shield.png");
            shield = i.getImage();
            stageFont = new Font("Courier New",Font.BOLD,20);
            lastAsteroidPosition = 0;
            scoreShow = "0000000000";
            shielded = true;
            try
                URL sound = new URL("file:///C:/Documents%20and%20Settings/dioNisio.OWLCITY/My%20Documents/NetBeansProjects/GamePractice/src/laserfast.au");
                shoot = Applet.newAudioClip(sound);
            catch(MalformedURLException e)
                System.out.print(""+e.getMessage());
            continued = true;
            createAsteroids();
        @Override
        public void run()
                start = System.currentTimeMillis();
                while(true)
                    if((System.currentTimeMillis() - start) >= 5000)
                        shielded = false;
                    animateStars();
                    animateAsteroids();
                    animateExplosion();
                    animateShots();
                    if(continued)
                        animateShip();
                        createShot();
                try {
                    Thread.sleep(5);
                } catch (InterruptedException ex) {
                    Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        public static void main(String[] args)
            Main newMain = new Main();
            Thread t1 = new Thread(newMain);
            t1.start();
        @Override
        public void paint(Graphics g)
            dbImage = createImage(getWidth(), getHeight());
            dbg = dbImage.getGraphics();
            paintComponent(dbg);
            g.drawImage(dbImage, 0, 0, this);
            repaint();
        public void paintComponent(Graphics g)
            g.setColor(Color.WHITE);
            for(int c = 0; c < 200; c++)
                g.setColor(stars[c].color);
                g.fillOval(stars[c].x, stars[c].y, (stars[c].radius * 2), (stars[c].radius * 2));
            for(int c = 0; c < asteroids.size(); c++)
                g.drawImage(asteroid,asteroids.get(c).x, asteroids.get(c).y, this);
            for(int c = 0; c < exploded.size(); c++)
                i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/e"+(exploded.get(c).explodeMode+1)+".png");
                explode = i.getImage();
                g.drawImage(explode,exploded.get(c).x, exploded.get(c).y, this);
                if(exploded.get(c).explodeMode < 14)
                    g.setColor(Color.white);
                    g.drawString("50",exploded.get(c).x, exploded.get(c).y);
            for(int c = 0; c < shots.size(); c++)
                g.drawImage(shot,shots.get(c).x, shots.get(c).y, this);
            if(!shipDestroyed)
                g.drawImage(ship, ship1.x, ship1.y, this);
                if(shielded)
                    g.drawImage(shield, ship1.x - 15, ship1.y - 15 , this);
            else
                if(ex<14)
                        i = new ImageIcon("C:/Documents and Settings/dioNisio.OWLCITY/My Documents/NetBeansProjects/GamePractice/src/e"+(ex+1)+".png");
                        explode = i.getImage();
                        g.drawImage(explode,ship1.x, ship1.y, this);
                        if((System.currentTimeMillis() - ship1.lastExplodeDisplay) >= 250)
                            ex++;
                            ship1.lastExplodeDisplay = System.currentTimeMillis();
                if(!continued)
                    g.setColor(Color.WHITE);   
                    g.drawString("PRESS F2 TO CONTINUE",470,50);
            g.setColor(Color.WHITE);
            g.setFont(stageFont);
            g.drawString("STAGE 1",20,50);
            g.setColor(Color.RED);
            for(int c = 0; c < ship1.lives; c++)
                g.drawString("♥",120+(c*10),50);
            g.setColor(Color.WHITE);
            g.drawString(""+ship1.score, 20, 70);
        public void animateStars()
            for(int c = 0; c < 200; c++)
                if(stars[c].y >= 460)
                    stars[c].y = 0;
                else
                    stars[c].y += stars[c].speed;
        public void animateShots() {
            boolean xTargeted = false, yTargeted = false, destroyed = false;
            for(int c = 0; c < shots.size() ; c++)
                for(int j = 0; j < asteroids.size(); j++)
                        if(((shots.get(c).x >= asteroids.get(j).x) && (shots.get(c).x < (asteroids.get(j).x + 30))) || (((shots.get(c).x + 30) >= asteroids.get(j).x) && ((shots.get(c).x + 30) < (asteroids.get(j).x + 30))))
                            xTargeted = true;
                        if((asteroids.get(j).y + 30 - shots.get(c).y) > 0)
                            yTargeted = true;
                        if(xTargeted && yTargeted)
                            exploded.add(asteroids.get(j));
                            asteroids.remove(j);
                            ship1.score += 50;
                            destroyed = true;
                        xTargeted = false;
                        yTargeted = false;
                if(destroyed)
                    shots.remove(c);
                    destroyed = false;
                else if(shots.get(c).y <=0)
                    shots.remove(c);
                else
                    shots.get(c).y -= shots.get(c).speed;
        public void animateAsteroids() {
            boolean xTargeted = false;
            boolean yTargeted = false;
            boolean sxTargeted = false;
            boolean syTargeted = false;
            for(int c = 0; c < asteroids.size() ; c++)
                if(shielded)
                    if(((ship1.x - 15 >= asteroids.get(c).x) && (ship1.x - 15 < (asteroids.get(c).x + 30))) || ((((ship1.x - 15) + 64) >= asteroids.get(c).x) && (((ship1.x - 15) + 64) < (asteroids.get(c).x + 30))))
                        sxTargeted = true;
                    if((asteroids.get(c).y + 30 - ship1.y) > 0)
                        syTargeted = true;
                    if(sxTargeted && syTargeted)
                        exploded.add(asteroids.get(c));
                        asteroids.remove(c);
                    sxTargeted = false;
                    syTargeted = false;
                else
                    if(((ship1.x >= asteroids.get(c).x) && (ship1.x < (asteroids.get(c).x + 30))) || (((ship1.x + 30) >= asteroids.get(c).x) && ((ship1.x + 30) < (asteroids.get(c).x + 30))))
                        xTargeted = true;
                    if((asteroids.get(c).y + 30 - ship1.y) > 0)
                        yTargeted = true;
                    if(xTargeted && yTargeted)
                        asteroids.remove(c);
                        shipDestroyed = true;
                        continued = false;
                        ship1.lives --;
                    xTargeted = false;
                    yTargeted = false;
                if(asteroids.get(c).y >=480)
                    asteroids.remove(c);
                else
                    asteroids.get(c).y += asteroids.get(c).speed;
        public void animateShip()
            if(keys[0] && !keys[1])
                if(ship1.x <= 15)
                    ship1.x = 15;
                else
                    ship1.x -= 5;
            else if(!keys[0] && keys[1])
                if(ship1.x >= 589)
                    ship1.x = 589;
                else
                    ship1.x += 5;
        public final void createStars()
            for(int c = 0; c < 200; c++)
                stars[c] = new Star();
        public void createShot()
            if(keys[2] && System.currentTimeMillis() - lastShot >= 150)
                Shot newShot = new Shot(ship1.x);
                shots.add(newShot);
                lastShot = System.currentTimeMillis();
                shoot.play();
        public final void createAsteroids()
            boolean verifiedGeneration = false;
            Asteroid newAsteroid = null;
            for(int c = 0; c < 100; c++)
                newAsteroid = new Asteroid();
                if((newAsteroid.y - lastAsteroidPosition) < 500)
                    newAsteroid.y -= (500 - (lastAsteroidPosition - newAsteroid.y));
                asteroids.add(newAsteroid);
                lastAsteroidPosition = newAsteroid.y;
        public void animateExplosion()
            for(int c = 0; c< exploded.size(); c++)
                if(exploded.get(c).y >= 480)
                    exploded.remove(c);
                else
                    exploded.get(c).y += exploded.get(c).speed;
                    if((System.currentTimeMillis() - exploded.get(c).lastExplodeDisplay) >= 150)
                        exploded.get(c).explodeMode++;
                        exploded.get(c).lastExplodeDisplay = System.currentTimeMillis();
    }So when I freshly run the program it works fine, but after a few shots and collisions with asteroids, the program throws an IndexOutOfBoundsException and I don't know where to trace it. I am beginning to think that the problem lies in my ArrayList. Here is a link to the program screenshot.
    Any help would be greatly appreciated.
    Thanks!
    Edited by: 893284 on Oct 26, 2011 4:59 AM

    First of all, put your program code between tags. Nobody's going to read unformatted code.
    Secondly, IOOBE is a very simple to understand exception. You're accessing a collection beyond its limits.
    Thirdly, the stacktrace will tell you where this happens. If you have multiple threads involved, you might need appropriate synchronization in there.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Quicktime 7.5 download

    Hi, how do i download the latest Quicktime 7.5 for my mac at home from a windows machine?

  • Run time error in me22n and me 23n

    Hi, first time in me22n if i edit something and press save,changes are getting saved perfectly and i am getting success message.so now its in display mode.if i press display<-> change icon,and do some changes and press save  i am getting run time err

  • Why are the wi-fi speeds bad even with my own rout...

    When I connect with an Ethernet, I get amazing speed of 74/76mb download. but soon as i connect via wi-fi with the hub or my own router, speeds dropped till about 20/25mbs.. whats causing the problem, I have tried to change channels but to no effect.

  • Database vs files

    My question is what is the advantage of using a database insted of a file to store the data for example if I store my data in a serialized object written to a file or as a structured file thanks

  • I just upgraded to Acrobat XI and found that my custom STAMPS are missing.

    I just upgraded to Acrobat XI and found that my custom STAMPS are missing. Anyone know how to pull them in from the last version? Macintosh. thanks