Applet won't run if put in JAR file

Hello, I've searched a lot and couldn't find an answer to my problem -
I want to put my applet into a jar file. and run it, of course.
I have a jar file that contains "b.class", "temp.class" both of them in directory "package_name", which is their package's name in eclipse. (this jar I obtained by using export from eclipse).
and - I have my index.html file -
<APPLET
CODE="b.class"
ARCHIVE "jar_file.jar"
WIDTH="100%" HEIGHT="90"
</APPLET>
both the index.html and the jar file in the same directory.
and the applet wont run!
what am I doing wrong? somehow I think that the problem is because the classes reside in another directory in the jar file,
but I already tried everything - with no success :(
Kogan.

OK the problem solved -here is highlighted what I was missing -
<APPLET
CODE=package_name.b.class ( I was missing the "package_name")
codebase = "."
ARCHIVE "jar_file.jar"
WIDTH="100%" HEIGHT="90"
</APPLET>
Edited by: Kogan on Nov 3, 2008 6:51 AM
Edited by: Kogan on Nov 3, 2008 6:52 AM

Similar Messages

  • Class Not Found Exception - applet won't run anywhere outside of IDE

    I have an applet that runs perfectly in the netbeans IDE, but won't run from command prompt (I'm using windows) or from a browser. I've been banging my head against the wall for a few days on this one. Here's the HTML I'm using:
    <applet width="400" height="525" code="musicapplet.class" archive="crypticgraffiti.jar">
    <param name="bgcolor" value="ffffff"> <param name="fontcolor" value="000000">
    </param> </param> Your browser is not Java enabled. </applet>
    Here is the structure of the jar file's contents:
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/crypticgraffiti/
    com/crypticgraffiti/music/musicapplet
    com/crypticgraffiti/music/GetNotes.class
    com/crypticgraffiti/music/InstList.class
    com/crypticgraffiti/music/Mode.class
    com/crypticgraffiti/music/MusicCreator.class
    com/crypticgraffiti/music/OctaveTransformer.class
    com/crypticgraffiti/music/Phrase.class
    musicapplet/MusicApplet$playerThread.class
    musicapplet/MusicApplet.class
    (Musicapplet.class is the main class)
    When I attempt to run from command prompt, I get:
    "Error: Could not find or load main class crypticgraffiti.MusicApplet"
    When I attempt to load via html:
    "basic: load: class musicapplet.class not found.
    load: class musicapplet.class not found.
    java.lang.ClassNotFoundException: musicapplet.class
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Exception: java.lang.ClassNotFoundException: musicapplet.class
    security: Accessing keys and certificate in Mozilla user profile: null"
    I have tried every possible variation for the 'code' element of the applet tag (package.mainclass.class, mainclass, mainclass.class, etc). I have also tried compiling with JDK 1.6 and this didn't change anything. I've tried clearing out the cache of temporary files using the java control panel settings, and have verified that my browser can run other applets using JRE 6 and 7.
    I've tried some different ways of distributing the applet, also: putting all the class files in the folder with the html file, putting the classes in a source folder in the same folder as the html file, and finally putting a jar in the same folder as the html file (which really seems the simplest).
    Any help at all would be most appreciated! This applet is a very cool and original music creating app that draws heavily on the JFugue API. It's a shame that I can't get it online for people to play with!

    Cryptic Graffiti wrote:
    Here is the structure of the jar file's contents:
    META-INF/
    META-INF/MANIFEST.MF
    com/
    com/crypticgraffiti/
    com/crypticgraffiti/music/musicapplet
    com/crypticgraffiti/music/GetNotes.class
    com/crypticgraffiti/music/InstList.class
    com/crypticgraffiti/music/Mode.class
    com/crypticgraffiti/music/MusicCreator.class
    com/crypticgraffiti/music/OctaveTransformer.class
    com/crypticgraffiti/music/Phrase.class
    musicapplet/MusicApplet$playerThread.class
    musicapplet/MusicApplet.class
    (Musicapplet.class is the main class)
    Please note that class names are case sensitive so "MusicApplet" is not same as "Musicapplet" or "musicapplet". Your applet tag should have fully qualified class name (without quotes) and should look like this:
    <applet width=400 height=525 code=musicapplet.MusicApplet archive="crypticgraffiti.jar">
    </applet>
    The JAR should be in the same directory as your HTML file. While launching from command line, you can also check if your JAR file is getting included in classpath.
    Thanks,
    Nitin

  • Images not getting Loaded while running Java Application through jar file

    Hello Friends,
    I have a problem while starting my application.I have written my application using pure java.There is no JSP or anything just pure swings.Mine is a standalone appplication.So i used to run it using a batch file.And when i used to start my application it used to not show me the images.so what i did was i mentioned the starting directory in the properties of the batch file (ie in the start in column field).But that was when i was using weblogic server.And i have lot of people working on the same application.so i used ZAC publisher in weblogic and along with that i used to publish the batch file also.so the users dint have any problem.But now what is my problem is i m trying to use JAVA Webstart instead of weblogic ZAC.Now in webstart what happens is that i have to run the appliaction thru jar file.so where do i mention the class path so that the images get loaded.As of now the imaes are not getting loaded.i feel this is a class path problem.but where do i mention it that is my problem.It would be really helpfule if someone could help me out.
    thanx and regards,
    [email protected]

    try out this
    ImageIcon img1=new ImageIcon(this.getClass().getResource(imagename));
    for exmaple
    Imageicon img1=new ImageIcon(this.getClass().getResource("name1.jpg"));
    dont 4get to include the image files in the jar file

  • Where put the JAR File jakarta-regexp-1.3.jar ?

    I'download jakarta-regexp-1.3.jar file from jakarta-apach site for validate a email adress..
    But i did not find any doc to telle me where put this file..
    I put it in the jre subdirectory of my sdk directory but the javac compiler
    do not recognize this part of my code import org.apache.regexp.* ..I try the lib directory of the tomcat and it was same..
    Where should i put this jar file ..
    By the way i 'm coding on linux for jakarta-tomcat server..
    Could some body help me ?

    DON'T CROSS POST:
    http://forum.java.sun.com/thread.jsp?thread=461653&foru
    =33&message=2116135
    http://forum.java.sun.com/thread.jsp?thread=461654&foru
    =45&message=2115945
    http://forum.java.sun.com/thread.jsp?thread=461653&foru
    =33&message=2115943
    http://forum.java.sun.com/thread.jsp?thread=461652&foru
    =1&message=2115941Ooops, didn't see it, ehmmmz
    I re-draw my answer, first learn some posting etiquette, then people might help.

  • Signed applets won't run @ web, only locally

    Hey, all elitist java folk, here is one for you:
    I have succeded in creating a signed, and an un-signed java applet - both run well locally. The signed applet, writes to a local file.
    Both are merely proof of concept.
    So, here is the deal:
    I upload both to a webserver (one of those where you get 50Mb for free) via ftp (not ASCII, binary transfer), and only the unsigned will run in my browsers (Opera, FF, MSIE tested).
    The signed one writes to the screen: "Could not instantiate."
    I belive the problem lies in the HTML, which is very basic but still works locally. I don't have any clsid-thingy, is this nessecary? Where do I read about this?
    HTML that (should) load the signed applet:
    <html>
    <applet code="localfile.class" archive="localfile.jar"  width="300" height="300">
    </applet>
    </body>
    </html>As previously said, the unsigned applet work both from the web and locally, so I won't post any more html here...
    Btw, I am not interessed in editing any policy-file; my signed applet should work "out-of-the-box" for any java-enabled browser on the Internet.
    All I want is for the browser to load the signed java applet, ask user for certificate confirmation, and run it... Just like with http://jupload.sourceforge.net/applet-basic.html , which also access local filesystem.

    If you open the Java Console what does it say?
    There shouldn't be any difference in loading the applet locally or from the webserver... presuming the HTML and jar files and classnames and stuff are all correct relative to both locations.

  • Java applets won't run on Safari???

    I have reinstalled Java twice, and it still won't run any Java applets. It just sits there with the cup logo and the arrow on either side. It works fine on Firefox but not Safari. Help?

    Hello
    I'm piggy backing on this thread because I too have had problems with Java and Safari
    Java runs fine for me in Firefox, however.
    I went to a federal website
    https://blrscr3.egs-seg.gc.ca/gol-ged/gov/browserdetection/BrowserCheck.html
    that uses java and received this message
    " Java applet unable to load
    To use this service, you must either install a recent version of the Sun JVM or enable "Scripting of Java applets" if it has been disabled."
    so i looked for an update and have downloaded and installed release 6, (at least, it said that it was installed, but have never been able to figure out where)
    when I check Java preferences, the choices are J2SE 1.4.2 or J2SE 5, and when I've switched to 1.4.2 I still have no luck.
    When i run firefox, i get the java console opening, but it doesn't open with safari, and I can't find the option for this to turn on in safari
    i have restarted both safari and my computer and no luck. I have repaired permissions and no changes have taken place.
    Any more suggestions?
    (thank you, by the way)

  • Applet won't run in browser

    I created an applet that writes and reads from a text file. It works when I run it in eclipse but not in a browser.
    Noob

    By default applets can't read the local filesystem. Presumably Eclipse lets you do it to make development easier. If you want your applet to read the local filesystem, you apparently have to sign it.

  • Applet won't run across server

    I am a JAVA beginner and I have made an applet compiled it and am calling the .class file with html page. It works perfectly on my pc in IE and firefox. The problem is that when I uploaded the files to a server they no longer work...just a red X and a applett failed message in the status bar.....
    any suggestions / help would be great! Thanks

    I see this in the Java console:
    java.lang.ClassFormatError: Extra bytes at the end of class file RumfordHW6
    This looks to me like RumfordHW6.class has been corrupted when
    moved to the server. How did you move it? Did you use BINARY FTP?
    Try to make absolutely sure your file and the server file are the same.

  • Can Netbeans put a jar file In a jar file?

    I just went through the process of getting Eclipse to create a jar file that would execute from a command prompt using a plugin called fatjar :
    http://fjep.sourceforge.net/
    Details from other thread :http://forum.java.sun.com/thread.jspa?threadID=5219638&tstart=0
    I really would like to use netbeans but i now have the exact same problem trying to make a jar file in netbeans 5.5.1
    I am using a package from icaste.com It has a
    .dll file to put in the windows directory
    JCommSerial_3_0.jar file that contains all the classes
    I can compile and run a file in the IDE and it works fine
    The Jar file does not contain the classes so i get errors when running from command line.
    Here is the layout of my screen and result of run command in IDE
    http://www.acousticlights.com/netbeans.png
    What do I need to try?

    georgemc wrote:
    Why is everyone so obsessed with doing this? The gains are minimal and the problems numerousBecause we are new and don't understand how the java VM actually runs code and the error messages sent by the java machine are cryptic.
    My first attempt at using an external jar in a java program lead me to believe that all of the code for a java program would be in a jar file including external jar files, after all the JDK standard library has tons of jars in it so I assumed the external jar file would be linked (as most other programming compiler/linkers I have worked with in my top down programming life).
    I find out the answer is so simple that the external jar file could not be found by the VM running my jar file. Like I said, if the VM would have just gave me an error that it could not find a file on a specific directory i never would have perused the idea of jar in a jar (fatjar plugin for Eclipse for example)
    Really this is like getting into a race car and not knowing at what RPM to shift gears, sure you can press the pedal and make it go but if you don't understand how it works under the hood you are going to blow the engine if you keep it in first gear.
    I have read many posts on these errors, the reason is the error message is just not very descriptive of the original problem. If I try and open a database called xyz.dbf that has one field defined as lastname, in C for example, I would not give the error message "Lastname could not be found) when indeed the lastname could not be found but the reason it could not be found was because the database xyz.dbf could not be found. Further , adding to the error message that the system is looking for xyz.dbf on drive X- subdirectory -mydatabases would complete the error message and allow the user to fix the error. Just what is a non java programmer that is using my java program suppose to do with an Ecception Error in (main) bla bla bla... I know now I need to check for library files myself within my own java programs and give a better error message to the user before the java VM sends out it's cryptic message.
    Edited by: metron9 on Sep 25, 2007 11:00 AM

  • Where do I put the .jar file for the database connection?

    I am trying to connect to an Oracle 11g database. I see under the coldfusion settings summary that the java version is 1.7.0_55. So I downloaded the ojdbc7.jar file from Abode.com. Now the question is where do I put it so that coldfusion can access it?
    Of course I need to set up the database connection (which I still don't have the connection string for), but I still need to know where to put the ojdbc.jar file.
    Thanks.

    jasonwryan wrote:What does the man page say?
           The  program  has builtin defaults and temperature thresholds but users
           can   specify   their   own    settings    in    configuration    files
           /etc/default/i8kmon  and  ~/.i8kmon.   The daemon defines 4 states with
           different fan speeds ({0 0}, {1 0}, {1 1}, {2 2}) and  for  each  state
           are  defined  the temperature thresholds which cause the switching to a
           higher or lower  state.  Furthermore  each  state  can  have  different
           thresholds  for operation on ac power or battery.  For example the fol‐
           lowing configuration:
    I've put the following file in /etc/default/i8kmon:
    # Run as daemon, override with --daemon option
    set config(daemon) 0
    # Automatic fan control, override with --auto option
    set config(auto) 1
    # Report status on stdout, override with --verbose option
    set config(verbose) 1
    # Status check timeout (seconds), override with --timeout option
    set config(timeout) 1
    # Temperature thresholds: {fan_speeds low_ac high_ac low_batt high_batt}
    set config(0) {{-1 0} -1 50 -1 50
    set config(1) {{-1 1} 50 70 50 70}
    set config(3) {{-1 2} 70 128 70 128}
    But it doesn't seem to do anything. I'm running a Dell Inspiron 3521 with no dedicated GPU, so it only has one fan. I was somehow able to get i8kmon to work in Ubuntu by putting this config in /etc/i8kmon, but can't get it to work in Arch. Putting it in /etc/i8kmon and /etc/default/i8kmon doesn't do anything.

  • How to run Java App in Jar file

    I can run Java App jar-ed into 1 jar file with java -jar App.jar
    But sometimes I need to jar only the app and bind the other classes from different place. So I tried to use:
    java -classpath c:\utils.jar -jar App2.jar
    where classes in App2.jar link to utils.jar. I just can't make it work. Any idea/help.
    thanks
    -ho

    hi HasanOen
    u need to edit the manifest file in yr JAR file u can do this by using the following cammand or by making the batch file but make sure all the files are in same folder.
    first of all u need to make a text file like below
    /////////// first file name: "THIS.txt" /////////
    Manifest-Version: 1.0
    Created-By: java // whatever here
    Main-Class: PUT YOUR MAIN CLASS NAME HERE (like MAIN)
    //////////////////// BATCH FILE "RUN.bat" //////////////
    jar cmf This.txt App2.jar MANIFEST.mf com
    com is the folder where your all the class file are.
    now double click the run.bat file. this will edit yr manifest file.
    hope this should work for u
    Note : Make sure yr jar file, txt file, bat file, and yr classes folder is in the same folder(I mean at same level)
    regards
    Satinderjit

  • NOT WORKING: Putting a jar file requiring native library in bootclasspath

    Hi,
    I put my own jar file into the bootclasspath like this:
    java -Xbootclasspath/p:myboot.jar TestClass
    Some classes in the jar require a native library. For JVM 1.3 on Solaris, I put the native library in $JAVA_HOME/jre/lib/sparc and everything works just fine.
    However, when I try the same thing on JVM1.4, I got the following error when my class containing the native methods is called:
    Failed to load the native library: myboot_native
    java.lang.UnsatisfiedLinkError: no myboot_native in java.library.path
    I tried to put that native library in several different directories in jre/lib but still had no luck.
    Is there anybody know the solution? Does JVM1.4 allow me to put a custom jar file that requires a native library in the bootclasspath?
    Regards,
    Eman

    Well is your file in a directory included in the java.library.path environement variable. I use java on windows but I have to add the directory where my native library is to the path variable (not classpath) in order to avoid the error you get.

  • Running exe contained in jar file

    Hello,
    I have written a java interface where an external executable is being called from one of the classes. I'm using Jgrasp as development environment.
    Everything works fine if I run the java program from within Jgrasp: the interface opens up fine and it can run the external program when the button which is supposed to start it is clicked on.
    I have then generated a JAR file containing all the classes etc and also the external executable.
    When I execute the Jar file, the interface opens up ok and everything works fine within it, but it cannot run the external executable any more.
    Is it possible to run an exe file contained in the jar file itself?
    I would like to distribute a single jar file containing all the files needed by the application.
    Thanks

    An EXE can only be executed from Java if it resides somewhere in the file system.
    This is obviously the case before you JAR the whole thing, but not after.
    Your code will need to extract the EXE by using Class.getResourceAsStream() and
    copy it to a temporary location in the file system before executing it.

  • Where to put custom .jar-files in order to use them in scripting QPAC?

    Hi,
    For testing purposes, I wrote a simple class and put it in a .jar-file to use in scripting QPAC. Unfortunately, I get the following error message in JBOSS:
    Class: FooBar not found in namespace
    Where do I have to put custom library (jar-)files in order for JBOSS to find them? I already tried
    [...]\jboss\lib as well as
    [...]\jboss\server\all\lib.
    Regards,
    Steve

    Hi Steve
    You need to put them in two places:
    1. In the server classpath, so that they can be found at runtime. jboss\server\all\lib should work, or you can even drop them into the server/all/deploy directory. I think if you put them in the lib directory, you need to restart Jboss, whereas if you put them in the deploy directory, they should be dynamically picked up.
    2. For testing purposes, the extra jars need to be in the classpath of the Workflow Designer. Please download our SQLPlus QPAC from:
    http://www.avoka.com/avoka/qpac_library.shtml
    It includes a document that describes a technique for adding extra jars to the classpath.
    Regards,
    Howard
    http://www.avoka.com

  • What is directory where I can put in jar file without specify classpath ?

    hi,
    Is there any directory in weblogic similar to the directory of WEB-INF/lib/ where I can throw a jar file in without specify classpath explicitly.
    The reason I'm looking for such directory is :
    -- I do not want to specify classpath explicitly
    -- I'd like it outside of an application so that it stay even if the application redeployed.
    Thanks

    Hi Aacc,
    The domain library directory that you are looking for is usually $DOMAIN_DIR/lib, for example "C:\Oracle\WLS_Middleware10.3.4\user_projects\domains\test_domain_1\lib" (Windows) or "/u01/weblogic/domains/my_domain/lib" (Linux/Unix).
    The jars located in this directory will be picked up and added dynamically to the end of the server classpath at server startup. The jars will be ordered lexically in the classpath. The domain library directory is one mechanism that can be used for adding application libraries to the server classpath.
    You can override the $DOMAIN_DIR/lib directory using the -Dweblogic.ext.dirs system property during startup. This property specifies a list of directories to pick up jars from and dynamically append to the end of the server classpath using java.io.File.pathSeparator as the delimiter between path entries.
    -Cris

Maybe you are looking for