NoClassDefFound in Applet

HI !
I'm getting a NoClassDefFound exception when trying put my applet in a package.When I dont use package statement everything works fine but as soon as I put the package statement i get following exception :
ava.lang.NoClassDefFoundError: Hej (wrong name: JavaFiler/Hej)
     at java.lang.ClassLoader.defineClass0(Native Method)
     at java.lang.ClassLoader.defineClass(Unknown Source)
     at java.security.SecureClassLoader.defineClass(Unknown Source)
     at sun.applet.AppletClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadCode(Unknown Source)
     at sun.applet.AppletPanel.createApplet(Unknown Source)
     at sun.plugin.AppletViewer.createApplet(Unknown Source)
     at sun.applet.AppletPanel.runLoader(Unknown Source)
     at sun.applet.AppletPanel.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
java.lang.NoClassDefFoundError: Hej (wrong name: JavaFiler/Hej)
     at java.lang.ClassLoader.defineClass0(Native Method)
     at java.lang.ClassLoader.defineClass(Unknown Source)
     at java.security.SecureClassLoader.defineClass(Unknown Source)
     at sun.applet.AppletClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadCode(Unknown Source)
     at sun.applet.AppletPanel.createApplet(Unknown Source)
     at sun.plugin.AppletViewer.createApplet(Unknown Source)
     at sun.applet.AppletPanel.runLoader(Unknown Source)
     at sun.applet.AppletPanel.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
�My html file looks like this
<HTML>
<HEAD>
<TITLE> Patricks Uppgift</TITLE>
</HEAD>
<BODY>
<CENTER>
<APPLET CODE="Hej"Width="450"Height="500">
</APPLET>
</CENTER>
</BODY>
</HTML>
[ /CODE]
My appletfile is in a directory Javafiler where the html also is and the classpath is set to both C.\ and C:\JavaFiler.
any suggestions anyone?
Greatful for all help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

Thanks for your reply but it seems not to be the problem. When I remove the package statement in my javafile it compile and runs without problemand the files are still in the same directory. The problem to me seems to be the package statement and how to get the html file to understand that the files are in the same directory as before but with a package statement.
Here's what I got changing the applet tag
   inl�sning: klassen �JavaFiler.Hej finns inte.
java.lang.ClassNotFoundException: �JavaFiler.Hej
     at sun.applet.AppletClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadCode(Unknown Source)
     at sun.applet.AppletPanel.createApplet(Unknown Source)
     at sun.plugin.AppletViewer.createApplet(Unknown Source)
     at sun.applet.AppletPanel.runLoader(Unknown Source)
     at sun.applet.AppletPanel.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\JavaFiler\�JavaFiler\Hej.class (The system cannot find the path specified)
     at java.io.FileInputStream.open(Native Method)
     at java.io.FileInputStream.<init>(Unknown Source)
     at java.io.FileInputStream.<init>(Unknown Source)
     at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
     at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
     at sun.applet.AppletClassLoader.getBytes(Unknown Source)
     at sun.applet.AppletClassLoader.access$100(Unknown Source)
     at sun.applet.AppletClassLoader$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     ... 10 more
java.lang.ClassNotFoundException: �JavaFiler.Hej
     at sun.applet.AppletClassLoader.findClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadClass(Unknown Source)
     at java.lang.ClassLoader.loadClass(Unknown Source)
     at sun.applet.AppletClassLoader.loadCode(Unknown Source)
     at sun.applet.AppletPanel.createApplet(Unknown Source)
     at sun.plugin.AppletViewer.createApplet(Unknown Source)
     at sun.applet.AppletPanel.runLoader(Unknown Source)
     at sun.applet.AppletPanel.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\JavaFiler\�JavaFiler\Hej.class (The system cannot find the path specified)
     at java.io.FileInputStream.open(Native Method)
     at java.io.FileInputStream.<init>(Unknown Source)
     at java.io.FileInputStream.<init>(Unknown Source)
     at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
     at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
     at sun.applet.AppletClassLoader.getBytes(Unknown Source)
     at sun.applet.AppletClassLoader.access$100(Unknown Source)
     at sun.applet.AppletClassLoader$1.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     ... 10 more
[ /CODE]

Similar Messages

  • Applet NullPointerException/noClassDefFound

    Hi,
    i'm new to Java and VERY new to applets. I have an applet that works fine when i start it from eclipse, but when i try starting it in a browser window i get the following Exception:
    Java(TM) Plug-in: Version 1.4.2_05
    C:/Inetpub/wwwroot/SampleFish/bichlbach.dxf
    java.lang.ExceptionInInitializerError
         at org.geotools.cs.LocalCoordinateSystem$Cartesian.<init>(LocalCoordinateSystem.java:87)
         at org.geotools.cs.LocalCoordinateSystem.<clinit>(LocalCoordinateSystem.java:106)
         at map.DefaultMapContext.<init>(DefaultMapContext.java:55)
         at dialogs.MainApplet.start(MainApplet.java:74)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NullPointerException
         at org.geotools.units.Unit.<clinit>(Unit.java:101)
         ... 6 more
    So everything in the namespace org.geotoos.... is in a package.
    I would think it's a nullpointer exception, but as it works fine when i start it from eclipse, it can't really be that.
    If i try to refresh the page, i get a noclassDefFound Exception:
    java.lang.NoClassDefFoundError
         at map.DefaultMapContext.<init>(DefaultMapContext.java:55)
         at dialogs.MainApplet.start(MainApplet.java:74)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    The initialisation of the class DefaultMapContext uses a class from the package the first time. So maybe there's something wrong with my classpath? But why does it find it the first time?
    Any help would be great!

    Hi,
    I also have receive same thing that. My applet work
    fine with Applet Viewer, but when i try with HTML
    page, it gets the sane error and deosn't work.
    Any help and guide!
    Hi liz, have you solve your work?
    May be guide me?
    ThanksNotice the previous posts occurred in September of 2004. It is not likely that you will get a response.
    When you say "I also receive the same thing..." do you mean you have the same identical error? That seems unlikely, especially since it works in AppletViewer. You probably have a different problem. It is nearly impossible to say what it is unless you post more information, especially the error message and code.
    I think the best approach is to try a simple Applet (like Hello World) to make sure you have the basics correct. If this works, start adding more and more of your code until it stops working. This will give you a clue as to what part of your code is causing the problem.

  • NoClassDefFound when running applet from a jar

    I have a project defined in Oracle JDeveloper 3.2 which runs fine with the appletviewer. However, when I create
    a JAR of the project (including all the libraries), Netscape gives me this error.
    java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleConnection
    at java.lang.ClassLoader.resolveClass(Compiled Code)
    at java.lang.ClassLoader.loadClassInternal(Compiled Code)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(Compiled Code)
    at oracle.jdbc.driver.OracleDriver.connect(Compiled Code)
    at java.sql.DriverManager.getConnection(Compiled Code)
    at java.sql.DriverManager.getConnection(Compiled Code)
    at Silly.myApplet.dbConnection(Compiled Code)
    at Silly.myApplet.doSqlQuery(Compiled Code)
    at Silly.myApplet.jbInit(Compiled Code)
    at Silly.myApplet.init(Compiled Code)
    * at netscape.applet.DerivedAppletFrame$InitAppletEvent.dispatch(Compiled Code)
    at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
    at java.awt.EventDispatchThread.run(Compiled Code)
    at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code)
    The class oracle/jdbc/driver/OracleConnection is in the JAR, as are the two called classes it claims not to find in these errors:
    # Verifier error oracle/jdbc/dbaccess/DBError.throwBatchUpdateException(Ljava/lang/String;Ljava/lang/String;II[I)V: Cannot find class java/sql/BatchUpdateException# Verifier error oracle/jdbc/driver/OracleConnection.initialize(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Loracle/jdbc/dbaccess/DBAccess;Ljava/util/Hashtable;)V: Cannot find class java/util/Map
    I would appreciate any help.
    TIA.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleConnectionI can think of a handful of reasons why you are getting that error message. But, let's see your html file, just that portion that deal with the <APPLET>, <OBJECT> and <EMBED> tags. I'm particularly interested in how you specify the jar file(s). Are you doing it this way:
    <APPLET CODE="myApp" CODEBASE="." ARCHIVE="myApp.jar,Oracle.jar" WIDTH=100 HEIGHT=100></APPLET>
    I am assuming that oracle libraries are in a jar file, are you putting that jar file inside of your jar file -- that would never work. If that's what you did, you must either extract the contents of libraries jar and then jar them together with your class files or keep the jar separate and use a manifest to specify the CLASSPATH.
    V.V.

  • Applets-NoClassDefFound:javax/swing/JApplet

    Does the jar,class,HTML files have to be on a server to run on the Web? They now reside
    on my C: drive and I get this message when I launch my HTML. Do I load the JAVA plug-in
    HTML converter here also? If it is possible to have the Web access the applets on my C: drive
    how do I point it to this location?

    Hi,
    Yes, your jar, class and HTML files need to reside on a server if you want them to be available for the web.
    Yes, you'll need to load the Java plug-in HTML converter here also. Normally, it will install only once but the code is required to let the browser know it needs to use another java plugin than the browser's default.
    I don't think you can point the applets from the server to your local drive. You can perhaps try to assign a drive letter on the server to your local drive and create a virtual directory pointing to this drive. If this works, the rest should also work (although this is not recommended).
    Kurt.

  • Help me:NoClassDefFound Exception

    Dear experts,
    I have my applet files in a folder c:\Date.
    As I needed to read the registry entry, I have
    downloaded a jar file that someone else created as a
    component.
    That jar file contains a class RegistryKey.
    I set the classpath to include c:\Date folder and
    c:\Date\jRegistry.jar file.
    I create an object for the class RegistryKey in the
    ationperformed event in my applet.
    The applet file compiled with no plm.
    but when running,when i click the button,it shows
    noClassdeffound exception as it fails to find
    RegistryKey class.
    Why is this happening?
    How can I make my applet access that class file that is inside another jar file?
    Thanks in advance
    Unique

    May be:
    package jRegistry.RegistryKey;
    in top of the file?

  • Plz help with this applet problem

    i made this player in jmf... and i tried to play file over http in it..
    player runs as applet in a jsp page.
    the prob is i was using .class file for the applet..but it wouldnt open a remote url coz applets run in sandbox mode...
    so i signed the applet..which caused it to end up in a jar..
    now the jar is perfectly playing remote urls..BUT
    it gives NoClassDefFound Error for ControllerListener class
    so
    1) with .class files it runs in all computers, but opens only files present on same servrer
    2) with .jar file it runs only on computers with jmf 2.1.1 installed, others giv the above error
    any ideas y this is so?
    and how do i add the whole javax.media package to teh jar if need be?
    i used:
    jar cvf test.jar PlayerApplet.java
    but how does ones add javax.media package?
    thanks

    Sorry. In that page I have to insert a CODE. I think I can get the code debugging the applet. Not the source code, a CODE that is in a class called Training.class
    <applet archive="http://www.mod-x.co.uk/mod_x_LeV_2/M_LeVeL3_od/7nf73b.jar" code="Training.class" width=300 height=50></applet>
    Cheers :D
    EDIT: Look, more logs in the java console when I leave the page:
    basic: New window ID: 0
    basic: Stopping applet ...
    basic: Removed progress listener: sun.plugin.util.GrayBoxPainter@ab835a
    basic: Finding information ...
    basic: Releasing classloader: sun.plugin.ClassLoaderInfo@db3331, refcount=0
    basic: Caching classloader: sun.plugin.ClassLoaderInfo@db3331
    basic: Current classloader cache size: 1
    basic: Done ...
    basic: Joining applet thread ...
    basic: Destroying applet ...
    basic: Disposing applet ...
    basic: Quiting applet ...
    basic: Joined applet thread ...
    Cheers :D
    Message was edited by:
    Tiger

  • Problem While using Applet Reqd classes using Weblogic 5.1

    Hi All,
    Here is my problem while using other classes from the Applet gives an error:NoClassDefFound,
    I have also put the applet reqd. classes in a jar file and placed this jar along with the applet
    in weblogic/myserver/serverclases,
    my tag in the html file is as follows:
    <applet code="MyApplet.class" archive="voucher.jar"
         codebase="/classes/" >
    </applet>
    is there any problem with my tag or directory structure,
    It would be great ful and thanks for helping in solving this problem.
    sai.

    Is this an issue with the "T-engine" or the "J-engine"? Are you using a
    ubbconfig file or weblogic.properties file? Can you post the stack trace?
    This may be an known issue and simply require you to install the latest
    service pack for WLS 5.1 (aka. J-engine)...
    Mary Ann Slavin wrote:
    Accordning to the Software Product Information (SPI) for WLE 5.1 it is
    available on the following Linux versions so this could be a problem
    with the version you are running.
    "BEA WebLogic Enterprise 5.1 software for Red Hat Linux 6.2 and Reliant
    Unix 5.45 is available separately. "
    MAS
    yajneesh Sabharwal wrote:
    hello friends,
    I have a Problem in Using Weblogic 5.1
    I am using weblogic 5.1 Enterprise on Linux 2.2.16 SuSE (7.0) with
    Dual Celeron 550MHz and 1GB RAM. The server runs our web application
    which uses the servelt, JSP and XSQL technology. The problem is
    that often i receive ASSERTION FAILURES where after the jsp's stop
    displaying content. Is this a Weblogic administration problem or
    the underlying OS problem. Kindly advice.
    Thankx in Advance
    Yajneesh sabharwal

  • Unable to browse an applet

    I created an applet through the Wizard, "Create a Project
    for a new Applet", I didn't add anything else to the program and
    I deployed it. It works correctly in JDeveloper, but I can't
    browse it with IE 4 or Navigator, though I added the ARCHIVE
    parameter to HTML file, referred to the jar file generated by
    JDeveloper.
    IE tells "load: class not found".
    Navigator tells "Applet error: java.lang.NoClassDefFound error:
    javax/swing/JApplet"
    null

    For information on applets, check the Technical FAQ in the
    Techinfo section. In the online help, general information on
    applet deployment is in the User's Guide -> User Reference ->
    Deploying Java Programs. For information on deploying InfoBus
    applets go to Building Java Forms using InfoBus... -> Deploying a
    Java Form.
    - PSW
    Lorenzo Rossetto (guest) wrote:
    : I created an applet through the Wizard, "Create a Project
    : for a new Applet", I didn't add anything else to the program
    and
    : I deployed it. It works correctly in JDeveloper, but I can't
    : browse it with IE 4 or Navigator, though I added the ARCHIVE
    : parameter to HTML file, referred to the jar file generated by
    : JDeveloper.
    : IE tells "load: class not found".
    : Navigator tells "Applet error: java.lang.NoClassDefFound error:
    : javax/swing/JApplet"
    null

  • JBDC problem in Java 1.3 Applet

    I am using win2000, oracle 9i, JDBC driver for Oracle 8.17, Java 1.3.
    When I programmed a JDBC application, works fine. When I transfers that to applet, I got "java.NoClassDefFound: oracle.jdbc.driver.OracleDriver()"
    But it is configured in the CLASSPATH and applications can find it.
    This is the relative code:
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    BTW whne I use Visual cafe and configure that in Environment setting. It works.
    So tthe proble seems to be: [JAVA]/bin/ appletViewer.exe didn't go to the windows OS to look at the CLASSPATH, right? (But it can find the classes in the same package!)
    Thanks for any comments.
    null

    You'll only see something in the console/log if something is put there. :)
    It will capture any output to System.out and System.err, includiing stack traces. But if your application doesn't put messages on these channels, and no exceptions are thrown, you won't see anything (of value) in the log.
    You had mentioned your application is 'freezing'. This could be caused by a number of things that wouldn't result in a stack trace. It could be a thread deadlock/starvation. You could be blocking on a resource that isn't getting loaded. There may be a badly implemented Applet lifecycle method that's causing the browser JVM to choke.
    Without being able to replicate this, or change the code, I'm afraid you're in for some major headaches. :(

  • Applet with IE6 Windows ME

    I write <applet code="BannerAlex" width=100 height=100>
    I see a gray space in my html document but the applet doesn't run
    I tried BannerAlex.class, but the same happens.
    and i get the message from the jvm console:
    Error loading class:BannerAlex
    java.lang.noclassDefFound error
    java.lang.ClassNotFoundException:BannerAlex
    I used FreeJava, and I have the file BannerAlex.class in the same directory of my html document which have the <applet> tag.
    Thank you very much

    I assume you're confident that your code is valid. If so, you're probably creating bytecodes that the MS jvm doesn't recognize. If you use any 1.2 or later features, that's a certainty. Otherwise, try using javac -target 1.1 xxx.java. If that won't work, you might get it to work by using old 1.1 libraries to compile with. If that all fails, use the plugin.

  • Problem with threads within applet

    Hello,
    I got an applet, inside this applet I have a singleton, inside this singleton I have a thread.
    this thread is running in endless loop.
    he is doing something and go to sleep on and on.
    the problem is,
    when I refresh my IE6 browser I see more than 1 thread.
    for debug matter, I did the following things:
    inside the thread, sysout every time he goes to sleep.
    sysout in the singleton constructor.
    sysout in the singleton destructor.
    the output goes like this:
    when refresh the page, the singleton constructor loading but not every refresh, sometimes I see the constructor output and sometimes I dont.
    The thread inside the singleton is giving me the same output, sometime I see more than one thread at a time and sometimes I dont.
    The destructor never works (no output there).
    I don't understand what is going on.
    someone can please shed some light?
    thanks.
    btw. I am working with JRE 1.1
    this is very old and big applet and I can't convert it to something new.

    Ooops. sorry!
    I did.
         public void start() {
         public void stop() {
         public void destroy() {
              try {
                   resetAll();
                   Configuration.closeConnection();
                   QuoteItem.closeConnection();
              } finally {
                   try {
                        super.finalize();
                   } catch (Throwable e) {
                        e.printStackTrace();
         }

  • Open web pages from an applet

    I'm developing an applet that has to open some web pages.
    The only way I know is to use the method showDocument that
    needs and URL. So, how to pass parameters to the web page?
    I don't want to put them in the URL: everyone can see
    "secret data"!
    Help me, please.

    Take a look at this example that uses a JEditor pane to hold the HTML page.
    //Create a new JEditor Pane
    jep = new JEditorPane( );
    //Ensure the pane is not editable
    jep.setEditable(false);  
    //Use this to get local HTML file
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");
    //add the html page to the JEditorPane
    jep.setPage(fileURL);Ok the core line of code here is this.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");The standard method for accessing a html file via a URL is thus. As you can see its very similar.
    URL fileURL = new URL("http://www.comp.glam.ac.uk/pages/staff/asscott/progranimate/docs/Manual/Manual.htm");this.getClass().getResourse() will return the file location of the class you are working with.
    By doing the following you can access manual.html in a folder called Manual that sits in the same file location as the class file you are using.
    URL fileURL = this.getClass().getResource("Manual/Manual.htm");I hope this helps.
    Andrew.

  • Unable to load database driver from my applet's jar file

    I'm trying to set up an applet that will talk to a MySQL database. I have no problem connecting to the database as I'm developing the code ("un-jarred"), but when I create a jar file of my code to test through a web browser, I cannot connect to the database due to the usual ClassNotFoundException. I have included mysql-connector-java-3.1.12-bin.jar (the current driver) in the jar, but I don't know if I'm supposed to supply some info through an attribute to the applet tag to let it know that the jar contains the driver it needs or if I have to call the driver differently in my code.
    Any help is appreciated, thanks.

    The simplest approach is always the best. :)Abso-lutely.
    Awesome, that worked perfectly. I Included the extra
    jar file in the applet tag and now my applet makes
    some sweet lovin' to the database.And you have succeeded where thousands have failed. Congratulations.

  • Applet java file not refreshing in browser

    I have an applet that I am updating and I am not seeing the corresponding update when I open the web page. I can manually download the java class file and look inside it and it definitely is the updated file. I have deleted the browser history. (I am running tests with Firefox 3, IE7, and Safari 4 public beta). Is there something else I need to do to make sure the browser pulls in the latest version of the class file referenced in the html?
    Here is the code:
    <HTML>
    <HEAD>
       <TITLE>A Simple Program</TITLE>
    </HEAD>
    <BODY>
       <CENTER>
          <APPLET CODE="SendRequest.class" WIDTH="500" HEIGHT="150">
          </APPLET>
       </CENTER>
    </BODY>
    </HTML>The applet refers to a hard coded URL to read through a urlconnection. It is always reading a file and showing content, but it is not showing the right file. If I change the name of the referenced file in the java program, it looks like the browser has cached the referred file, rather than throwing and error and saying the file doesn't exist.
    Here is the java
    import java.applet.*;
    import java.awt.*;
    import java.net.URLConnection;
    import java.net.URL;
    import org.w3c.dom.Document;
    import java.lang.String;
    import java.io.*;
    public class SendRequest extends Applet {
        @Override
        public void paint(Graphics g) {
            g.drawRect(0, 0, 499, 149);
            g.drawString(getResponseText(), 5, 70);
        public String getResponseText() {
            try {
                URL url = new URL("http://myserver.com/stats/logs/ex20090603000001-72.167.131.217.log");
                URLConnection urlconn = url.openConnection();
                BufferedReader in = new BufferedReader(
                                    new InputStreamReader(
                                    urlconn.getInputStream()));
                String inputLine;
                String htmlFile = "";
                try {
                    while ((inputLine = in.readLine()) != null)
                        htmlFile += inputLine;
                    in.close();
                    return htmlFile;
                } catch (Exception e) {
                    return "Can't get the string.";
            } catch (Exception e) {
                return "Problem accessing the response text.";
    }Any help would be appreciated. I heard that some files may cache more persistently than others, but I don't fully understand the details.
    Thanks,
    Jim

    Check this [document loader example|http://pscode.org/test/docload/] & follow the link to sandbox.html for tips on clearing the class cache. That relates specifically to caching a refused security certificate, but class caching is much the same. As an aside, getting a console can be tricky in modern times (unless the applet fails completely). It is handy to configure the [Java Control Panel|http://java.sun.com/docs/books/tutorial/information/player.jnlp] to pop the Java console on finding an applet (Advanced tab - Settings/Java Console/Show Console).
    Of course there are two better tools for testing applets, especially in regard to class caching. AppletViewer and Appleteer both make class refresh fairly easy. Appleteer is the better of the two. I can tell you that with confidence, since I wrote it. ;-)

  • EJB 3.0 - Communicate an Applet with a Session Bean

    Hello
    I'm developing an EJB 3.0 app (eclipse and glassfish tools bundle), and I have an applet that has to use remote session beans.
    QUESTION: Is it possible for the applet to connect to EJB?
    QUESTION: By creating a J2EE application client project, can I use @EJB annotations to inject the session bean directly to the applet, avoiding the JNDI lookup?
    (since I imagine that the anwser to the second one is NO, I do the following consideration)
    Given an application client project, I imagine that this application can run remotely on a client machine/JRE. Then this application can use Annotations/injection facilities whenever it runs on a J2EE client container (which I assume consists of a set of libraries provided by the application server vendor, Glassfish in that case). Could this application be deployed using Java Web Start? If so, why can't it be deployed as an applet? (both options run in a client JRE, don't they?).
    QUESTION: In either case (applet or JWS), how do I have to package the JAR file (using Eclipse) so that it contains the needed libraries for accessing the EJB? Which are those libraries?
    At the time being, I'm trying to implement a sample application that follows the "Applet doing JNDI lookup" approach. I have:
    - an EAR project
    - an EJB project (containing an Entity Bean and a Stateless Session Bean with a @Remote interface)
    @Remote
    public interface HelloRemote {
         public String hello(String name);
    @Stateless
    public class Hello implements HelloRemote {
         @Override
         public String hello(String name) {
              return "Hello "+name+"!!";
    }- an Application Client project (containing the applet code):
    public class ClientApplet extends JApplet {
         public void init(){     
              try {
                   Context jndiContext = getInitialContext( );
                   HelloRemote server = (HelloRemote) jndiContext.lookup(HelloRemote.class.getName());
                   setContentPane(new JLabel(server.hello("Gerard")));
              } catch (NamingException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         private Context getInitialContext() throws NamingException{
              Properties props = new Properties();
              props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
              props.setProperty("org.omg.CORBA.ORBInitialHost", "myhost");
              props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
              return new InitialContext(props);
    }- a static web project (with a sample web page that contains the applet object the corresponding applet JAR file)
    I tried to export the Application Client project as an "application client JAR", in the hope that the java EE libraries bundled with glassfish (listed as libraries of this project) would be packaged too.
    No success, so now I'll try to copy all the JAR files (one by one) into the +\WebContent\+ folder of the Web Project, and add references to each of them in the archive="" attribute of the +<applet>+ HTML tag. Although this might work, I suspect that I am missing the good/easy way of doing it. Any suggestions?
    Thanks in advance,
    Gerard
    Edited by: gsoldevila on May 6, 2009 7:09 AM

    An Applet can communicate with an EJB via JNDI lookup but I would (personally) use an intermediate Servlet to handle this. Client to Servlet communication is http whereas to ejb is iiop - which might be blocked.
    Injection only works in managed classes (EJB, Servlet, Listeners..) and an Application Client main class. So yes you could use an app client for handling resource injection.
    m

Maybe you are looking for