Simple applet jar question

I'm sure this is an easy question, but how do you access subdirectories in your applet's jar file?
For instance the contents of MyApplet.jar jar would be:
* META-INF
* images
* net
Say the main class is MyApplet.class in net/mydomain/myproject
How in the main class would I get at images/MyImage.jpg?
Obviously I did not get this code to work:
ImageIcon upIcon = new ImageIcon("images/MyImage.jpg");
Thanks alot!

Actually now I am using:
ImageIcon upIcon = new ImageIcon(MyApplet.class.getResource("/images/MyImage.jpg"));
This way the 'absolute' resource is found (becuase the resource name starts with a '/').
This seems to be the best way to do it.

Similar Messages

  • Question about Java Applet Jar file signing.

    These questions pertain to Java 6 Standard Edition 1.6.0_22-b04 and later.
    I have gone through the Oracle Java Tutorial for generate public and private key information
    to sign a jar file, and how to sign the jar itself, all at
    [http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html|http://java.sun.com/developer/onlineTraining/Programming/JDCBook/signed.html]
    , and seek some clarification on the following related questions:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?
    -using the policytool policy file generator, what do I need to add under "Principals"
    (if anything) when dealing with a Java applet? Are Codebase and SignedBy simply author information?
    -If I choose to use a java.security.Permission subclass object set up in equivalent fashion within the Applet,
    which class within the Applet jar do I instantiate that object in? Does it need to be mentioned
    in the applet's jar Manifest.MF file?
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?
    -With this being the case, can the applet now escape
    the sandbox, be it with or without the stipulated
    policy permissions?

    848439 wrote:
    -In order to "escape" the java applet sandbox that exists around the client's
    copy of the applet running in their web browser, ie.
    (something forbidden by default), is verification of the signed applet enough, or is a policy file required
    to stipulate these details?Just sign the applet, the policy file is not necessary.
    -Is the "keystore database" a java language service/process which runs in
    the Server's memory and is simply accessed and started by default
    by the client verifier program (appletview/web browser)?No.
    -The public key certificate file (*.cer) is put in the webserver directory holding
    the Applet jar file (ie. Apache Tomcat, for example).No. For a signed Jar, all the information is contained inside the Jar.
    -Presumably, the web browser detects the signed jar
    and certificate file, and provides the browser pop up menu asking the user
    about a new, non recognised certificate (initially).
    Is this so?No. It is the JVM that determines when to pop the confirmation dialog.
    -With this being the case, can the applet now escape
    the sandbox, ..Assuming the end-user OK's the trust prompt, yes.
    ..be it with or without the stipulated
    policy permissions?Huh?

  • BigIP F5 : changing IP leads to cache invalidated and redownload of applet jars

    Hello all,
    In short, I'm trying to figure out how to have the java 7 plugin not considering the server IP to decide whether to use cached version of our applet's signed jars.
    As suggested in the title, we use BigIP's F5 boxes to dispatch requests among actual servers, which are located in 2 different sites (disaster recovery purposes).
    Each site has an F5 box ; and our DNS resolve the application's host name by alternating between 2 different IPs : one for site 1, the other for site 2.
    Each time a user visits http://theapp.mycompany.com, the host is resolved as 9.9.9.1 or 9.9.9.2, more or less randomly.
    This works very nicely as long as the applet is not concerned, or bandwith and latency is good enough to absorb 1.5Mb in a snap.
    For remote subsidiaries (10.000km away from servers), downloading 1.5Mb takes 35s -- too much for the normal user to wait.
    And the problem is : the plugin insists on looking up the server IP each time it starts up, and ignores cache entries that have been downloaded from a different IP.
    Here is the use case :
    - user connects to http://theapp.mycompany.com ; the browser get an IP, doesn't matter which ; user logs on, navigates in the app's html pages -- no problem
    - user gets to the applet :
    - the html page says
    <applet id="myApplet">
        <param name="archive" value="a.jar,b.jar,c.jar,d.jar,e.jar"/>
        <param name="codebase_lookup" value="false"/>
        <param name="archive_1" value="a.jar, preload, version=7.5.7" />
        <param name="archive_2" value="b.jar, preload, version=7.5.7" />
        <param name="archive_3" value="c.jar, preload, version=7.5.7" />
        <param name="archive_4" value="d.jar, preload, version=7.5.7" />
        <param name="archive_5" value="e.jar, preload, version=7.5.7" />
        <param name="baseUrl" value="/"/>
        <param name="code" value="a/package/for/Applet.class"/>     
        <param name="mayscript" value="mayscript"/>
        <param name="codebase" value="/applet/"/>
        <param name="name" value="MyApplet" />"
        <param name="locale" value="fr"/>
    </applet>
         The archive_n parameters are here in an attempt to tell the plugin to not even ask for jars if its cache contains entries with same host/same name/same version.
         The version is assigned at build time at an application level ; it has nothing to do with the Implementation-Version attribute found in MANIFEST.MF files.
    - Java and the plugin sarts up : let's assume this is the first time : cache is empty : all jars are downloaded ; as they are signed and the CA certificate chain was set in the browser config, and the java.policy is also configured to allow smooth exec, the applet runs smoothly -- after a long startup delay
    - user leaves the applet, do some stuff in other applet-less pages for some minutes (the java/plugin processes are shut down after a minute or so)
    - user reenters the page that contains the applet
    - Java and the plugin start up again :
         - the cache has entries for each jar : host, name, version are all ok.
         - But : the jars are not seen as "prevalidated" ; heres' the applet log ( in French, translation provided after "//") :
    network: Vérification de version pour a.jar. La version spécifiée est 7.5.7     //Checking version for a.jar. Specified version is 7.5.7
    security: La vérification de révocation de la liste noire est activée     // Check of blacklist revocation is activated
    security: blacklist: created: NEED_LOAD, lastModified: 1378474147992
    security: blacklist: hasBeenModifiedSince 1380806409906 (we have 1378474147992)
    security: La vérification de liste de bibliothèques sécurisées est activée     // Check of trusted libraries is activated
    ..... same for the other jars ....
    network: Created version ID: 7.5.7
    network: Created version ID: 7.5.7
    network: Entrée de cache trouvée [URL : http://theapp.mycompany.com/applet/a.jar, version : 7.5.7] prevalidated=false/0  //Cache entry found
    cache: Adding MemoryCache entry: http://sandbox-mosaic.jcdecaux.com/applet/plannerApplet_7.5.7.jar
    network: Created version ID: 7.5.7
         - The plugin then tries to lookup the host IP to check whether it matches that seen when creating the entry
         - 2 possibilities here :
                   - the IP returned is the same : the plugin is happy, uses the cached jar, no question/download to/from the server, and the applet starts up quick and runs ok
                   - the IP returned is not the same ; the plugin says :
    network: Vérification de version pour a.jar. La version spécifiée est 7.5.7     //Checking version for a.jar. Specified version is 7.5.
    security: blacklist: created: NEED_LOAD, lastModified: 1378474147992
    security: blacklist: hasBeenModifiedSince 1380806409906 (we have 1378474147992)
    security: La vérification de liste de bibliothèques sécurisées est activée     // Check of trusted libraries is activated
    cache: CacheEntry IP mismatch: 9.9.9.1 != 9.9.9.2
              and then it downloads again the jar.
              Of course, all the jars are treated the same way.
              Note that the applet eventually runs normally ; the only problem is that the cache essentially doesn't work, causing terribly annoying 35s delays at applet startup.
    Interestingly enough, examining the jdk 6 code shows that the "prevalidated=false" fragment (in bold/pink above) means that the method CacheEntry.isKnownToBeSigned() returns false.
    I tried with a self-signed certificate which I added first in IE as "Trusted publisher" ; I also tried with a certificate signed by a CA that is known by IE -- no help.
    So I really wonder : what does it take to have the plugin consider that each jar "isKnownToBeSigned" ?
    Any thoughts ?
    Note : we of course are considering packing jars, cleaning dead code, etc. to decrease applet size. But it doesn't help with the fact that the plugin considers the IP, which it shouldn't do in our case. And even with pack200 we're left with +350Kb of unnecessary downloads, not counting with future code to be developped ...
    Thanks for any feedback
    David
    Browser is IE7.
    Complete dump of system properties :
    __applet_launched = 280874909499
    __jvm_launched = 280874910680
    acl.read = +
    acl.read.default =
    acl.write = +
    acl.write.default =
    awt.toolkit = sun.awt.windows.WToolkit
    browser = sun.plugin
    browser.vendor = Oracle
    browser.version = 1.1
    file.encoding = Cp1252
    file.encoding.pkg = sun.io
    file.separator = \
    file.separator.applet = true
    http.agent = Mozilla/4.0 (Windows Vista 6.0)
    http.auth.serializeRequests = true
    https.protocols = TLSv1,SSLv3
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    java.class.path = C:\tools\Java\jre7\classes
    java.class.version = 51.0
    java.class.version.applet = true
    java.endorsed.dirs = C:\tools\Java\jre7\lib\endorsed
    java.ext.dirs = C:\tools\Java\jre7\lib\ext;C:\Windows\Sun\Java\lib\ext
    java.home = C:\tools\Java\jre7
    java.io.tmpdir = C:\Users\taille\AppData\Local\Temp\
    java.library.path = C:\tools\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Internet Explorer;;C:\oracle\ORA102\bin;C:\Perl\site\bin;C:\Perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;c:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\JavaSoft\JRE\1.3.1_06\bin;C:\ORACLE\Ora92\jre\1.3.1\bin;C:\ORACLE\Ora92\jre\1.1.8\bin;C:\tools\Groovy-1.7.5\bin;C:\tools\Graphviz2.28\bin;C:\tools\Git\cmd;C:\tools\tortoiseSVN\bin;C:\Program Files\Windows Imaging\;C:\oracle\ORA102\bin;C:\Perl\site\bin;C:\Perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;c:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\JavaSoft\JRE\1.3.1_06\bin;C:\ORACLE\Ora92\jre\1.3.1\bin;C:\ORACLE\Ora92\jre\1.1.8\bin;C:\tools\Groovy-1.7.5\bin;C:\tools\Graphviz2.28\bin;C:\tools\Git\cmd;C:\tools\tortoiseSVN\bin;C:\Program Files\Windows Imaging\;.
    java.protocol.handler.pkgs = sun.plugin.net.protocol|com.sun.deploy.net.protocol
    java.rmi.server.RMIClassLoaderSpi = sun.plugin2.applet.JNLP2RMIClassLoaderSpi
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.7.0_21-b11
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Oracle Corporation
    java.specification.version = 1.7
    java.vendor = Oracle Corporation
    java.vendor.applet = true
    java.vendor.url = http://java.oracle.com/
    java.vendor.url.applet = true
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/
    java.version = 1.7.0_21
    java.version.applet = true
    java.vm.info = mixed mode, sharing
    java.vm.name = Java HotSpot(TM) Client VM
    java.vm.specification.name = Java Virtual Machine Specification
    java.vm.specification.vendor = Oracle Corporation
    java.vm.specification.version = 1.7
    java.vm.vendor = Oracle Corporation
    java.vm.version = 23.21-b01
    javaplugin.nodotversion = 10212
    javaplugin.version = 10.21.2.11
    javaplugin.vm.options = -Ddeployment.trace.level=all -Duser.language=en
    javawebstart.version = javaws-10.21.2.11
    line.separator = \r\n
    line.separator.applet = true
    mrj.version.applet = true
    os.arch = x86
    os.arch.applet = true
    os.name = Windows Vista
    os.name.applet = true
    os.version = 6.0
    os.version.applet = true
    package.restrict.access.com.sun.deploy = true
    package.restrict.access.netscape = false
    package.restrict.access.org.mozilla.jss = true
    package.restrict.access.sun = true
    package.restrict.definition.com.sun.deploy = true
    package.restrict.definition.java = true
    package.restrict.definition.netscape = true
    package.restrict.definition.org.mozilla.jss = true
    package.restrict.definition.sun = true
    path.separator = ;
    path.separator.applet = true
    sun.arch.data.model = 32
    sun.awt.enableExtraMouseButtons = true
    sun.awt.warmup = true
    sun.boot.class.path = C:\tools\Java\jre7\lib\resources.jar;C:\tools\Java\jre7\lib\rt.jar;C:\tools\Java\jre7\lib\sunrsasign.jar;C:\tools\Java\jre7\lib\jsse.jar;C:\tools\Java\jre7\lib\jce.jar;C:\tools\Java\jre7\lib\charsets.jar;C:\tools\Java\jre7\lib\jfr.jar;C:\tools\Java\jre7\classes;C:\tools\Java\jre7\lib\deploy.jar;C:\tools\Java\jre7\lib\javaws.jar;C:\tools\Java\jre7\lib\plugin.jar
    sun.boot.library.path = C:\tools\Java\jre7\bin
    sun.cpu.endian = little
    sun.cpu.isalist = pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
    sun.desktop = windows
    sun.io.unicode.encoding = UnicodeLittle
    sun.java.command = sun.plugin2.main.client.PluginMain write_pipe_name=jpi2_pid7004_pipe37,read_pipe_name=jpi2_pid7004_pipe36
    sun.java.launcher = SUN_STANDARD
    sun.jnu.encoding = Cp1252
    sun.management.compiler = HotSpot Client Compiler
    sun.net.client.defaultConnectTimeout = 120000
    sun.net.http.errorstream.enableBuffering = true
    sun.os.patch.level = Service Pack 2
    trustProxy = true
    user.country = FR
    user.dir = C:\dtaille\TMA\perfs_br\newcert
    user.home = C:\Users\taille
    user.language = fr
    user.name = taille
    user.script =
    user.timezone = Europe/Paris
    user.variant =
    Vider les propriétés de déploiement...
    active.deployment.proxy.bypass.local = false
    active.deployment.proxy.same = false
    active.deployment.proxy.type = 3
    deployment.baseline.url = https://javadl-esd-secure.oracle.com/update/baseline.version
    deployment.blacklist.url = https://javadl-esd-secure.oracle.com/update/blacklist
    deployment.blacklisted.certs.url = https://javadl-esd-secure.oracle.com/update/blacklisted.certs
    deployment.browser.path = C:\Program Files\Mozilla Firefox\firefox.exe
    deployment.browser.vm.iexplorer = true
    deployment.browser.vm.mozilla = true
    deployment.cache.enabled = true
    deployment.cache.jarcompression = 0
    deployment.cache.max.size = 726
    deployment.capture.mime.types = false
    deployment.console.startup.mode = SHOW
    deployment.control.panel.log = false
    deployment.expiration.decision.10.21.2 = later
    deployment.expiration.decision.suppression.10.21.2 = true
    deployment.expiration.decision.timestamp.10.21.2 = 9/6/2013 15:29:3
    deployment.insecure.jres = PROMPT
    deployment.javafx.mode.enabled = true
    deployment.javapi.cache.update = false
    deployment.javapi.lifecycle.exception = false
    deployment.javapi.log.filename =
    deployment.javapi.runtime.type = 0
    deployment.javapi.stop.timeout = 200
    deployment.javapi.trace.filename =
    deployment.javaws.appicon.index = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\appIcon\appIcon.xml
    deployment.javaws.associations = ASK_USER
    deployment.javaws.cache.update = false
    deployment.javaws.concurrentDownloads = 4
    deployment.javaws.install = IF_HINT
    deployment.javaws.installURL = http://java.sun.com/products/autodl/j2se
    deployment.javaws.logFileName =
    deployment.javaws.muffin.max = 256
    deployment.javaws.shortcut = ASK_IF_HINTED
    deployment.javaws.splash.index = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\splash\splash.xml
    deployment.javaws.traceFileName =
    deployment.javaws.uninstall.shortcut = false
    deployment.javaws.update.timeout = 1500
    deployment.javaws.viewer.bounds = 1723,197,881,546
    deployment.jpi.mode.new = true
    deployment.log = false
    deployment.macosx.check.update = true
    deployment.max.output.file.size = 10
    deployment.max.output.files = 5
    deployment.mime.types.use.default = true
    deployment.modified.timestamp = 1380804178316
    deployment.proxy.bypass.local = false
    deployment.proxy.override.hosts =
    deployment.proxy.same = false
    deployment.proxy.type = 3
    deployment.security.SSLv2Hello = false
    deployment.security.SSLv3 = true
    deployment.security.TLSv1 = true
    deployment.security.TLSv1.1 = false
    deployment.security.TLSv1.2 = false
    deployment.security.askgrantdialog.notinca = true
    deployment.security.askgrantdialog.show = true
    deployment.security.authenticator = true
    deployment.security.blacklist.check = true
    deployment.security.browser.keystore.use = true
    deployment.security.clientauth.keystore.auto = true
    deployment.security.disable = false
    deployment.security.https.warning.show = false
    deployment.security.jsse.hostmismatch.warning = true
    deployment.security.level = HIGH
    deployment.security.local.applets = PROMPT
    deployment.security.mixcode = DISABLE
    deployment.security.notinca.warning = true
    deployment.security.password.cache = true
    deployment.security.run.untrusted = PROMPT
    deployment.security.sandbox.awtwarningwindow = true
    deployment.security.sandbox.casigned = PROMPT
    deployment.security.sandbox.jnlp.enhanced = true
    deployment.security.sandbox.selfsigned = PROMPT
    deployment.security.trusted.policy =
    deployment.security.validation.crl = false
    deployment.security.validation.ocsp = false
    deployment.security.validation.ocsp.publisher = false
    deployment.system.cachedir = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\SystemCache
    deployment.system.security.blacklist = C:\tools\Java\jre7\lib\security\blacklist
    deployment.system.security.cacerts = C:\tools\Java\jre7\lib\security\cacerts
    deployment.system.security.jssecacerts = C:\tools\Java\jre7\lib\security\jssecacerts
    deployment.system.security.oldcacerts = C:\tools\Java\jre7\lib\security\cacerts
    deployment.system.security.oldjssecacerts = C:\tools\Java\jre7\lib\security\jssecacerts
    deployment.system.security.trusted.certs = C:\tools\Java\jre7\lib\security\trusted.certs
    deployment.system.security.trusted.clientauthcerts = C:\tools\Java\jre7\lib\security\trusted.clientcerts
    deployment.system.security.trusted.jssecerts = C:\tools\Java\jre7\lib\security\trusted.jssecerts
    deployment.system.security.trusted.libraries = C:\tools\Java\jre7\lib\security\trusted.libraries
    deployment.system.tray.icon = true
    deployment.trace = true
    deployment.update.mime.types = true
    deployment.user.cachedir = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\cache
    deployment.user.extdir = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\ext
    deployment.user.logdir = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\log
    deployment.user.security.blacklist = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\blacklist
    deployment.user.security.blacklist.dynamic = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\blacklist.dynamic
    deployment.user.security.blacklisted.certs = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\blacklisted.certs
    deployment.user.security.policy = file:/C:/Users/taille/AppData/LocalLow/Sun/Java/Deployment/security/java.policy
    deployment.user.security.sandbox.certs = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\sandbox.certs
    deployment.user.security.saved.credentials = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\auth.dat
    deployment.user.security.trusted.cacerts = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\trusted.cacerts
    deployment.user.security.trusted.certs = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\trusted.certs
    deployment.user.security.trusted.clientauthcerts = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\trusted.clientcerts
    deployment.user.security.trusted.jssecacerts = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\trusted.jssecacerts
    deployment.user.security.trusted.jssecerts = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\trusted.jssecerts
    deployment.user.security.trusted.libraries = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\security\trusted.libraries
    deployment.user.tmp = C:\Users\taille\AppData\LocalLow\Sun\Java\Deployment\tmp
    deployment.version = 7.21
    deployment.webjava.enabled = true
    java.quick.starter = false

    This behavior was introduced by a security "fix" intended to prevent a DNS re-binding attack which permits unsigned applets to escape the applet sandbox.  The "fix" was, imo, very poorly thought out.  You think you have a problem with 1.5 megabits of applet jars, but I have 8 megabytes, hundreds of thousands of users, with lousy networks. So now I'm stuck with a colocation vendor.  Imagine my chagrin when they changed *their* ISP and thus their IP addresses.  
    As far as I can see, signed applets are already permitted (if the user allows) to communicate outside the sandbox, so this "fix" should not have been applied to signed jars, only to unsigned ones.  There are a couple of other techniques that Oracle might have used to prevent this attack, but they chose the simplest one, effectively preventing anyone from using the most common, inexpensive strategies for improving the availability of their web-based Java applications.

  • Applet jar creation

    I am creating a web application, and the server side objects are fairly simple to create with the NDS.
    Now I want to create some applets and create the JAR for deployment within my web application.  To add, the applet passes objects back and fourth to the server, so my web application will need to be aware of the classes in the applet application.
    How do I do this within NDS?

    hi nathan,
              first thing add your applet jar file in the java build path of your project.
               while accessing the method at runtime of these jar file pass the required objects.
    regards,
    guru

  • Certificate inquiry for changes in applet jar

    Hi everybody,
    I have an applet that uses a certificate to allow saving of file to local disk. I downloaded the certificate and imported in the keystore and cacerts using keytool.
    However, there are cases we need to change the applet. I updated the jar file with the revised version of applet.
    My question is: Do I need to change the certificate and perform again the importing to keystore and cacerts to point the the revised applet so that I could save a file to local disk?
    My concern is that what if many users have already performed the certificate importing, do they need to do again the procedure of importing certificate.
    Your comments are very appreciated.
    Thanks!
    vamendoza

    You should only need to re-sign the applet jar with the same certificate.

  • Simple applet, curious yellow sign...

    This maybe a noob thing that I have run into. I have looked on some of the threads but can't find anything that relates to my specific problem. Below is a simple applet that displays a input message box user puts in name and it displays a greeting nothing fancy just something basic.
    I loaded the .class file on to the freewebs<dot> com server where my site is hosted at and did the applet tag and it runs. The only problem is it displays a yellow glow around the applet box and a yellow information warning. I did the reading on applets from the tutorial and didn't come across anything that mentioned anything like this, maybe I missed it. When I run the applet on the web it doesn't show any error messages or codes just that yellow information warning. How can I fix this.
    import javax.swing.JApplet;
    import javax.swing.JOptionPane;
    public class HelloFromBlahWebsite extends JApplet
              public void start()
                   String sName;
                   sName = JOptionPane.showInputDialog(null,
                   "What is your name?","Welcome to My Page",
                   JOptionPane.QUESTION_MESSAGE);
                   JOptionPane.showMessageDialog(null,
                   "Greetings From Me and welcome to my site,  " + sName + "!", "Greetings",
                   JOptionPane.INFORMATION_MESSAGE);
         }

    0xfeedadeadf15h wrote:
    How can I fix that?You don't. That's pretty much the idea ...
    Or a better question would be how do I get the applet signed so it doesn't show up?... unless of course you sign your applet. To do this you'll need to get a certificate, which costs quite some money.

  • Trying to add a simple applet to a web page

    Well, I was trying to add a simple applet to a web page(php nuke Home section), it didn't fin my applet, so I changed it and added it to a simple html file to make it as simple as I could get it.
    This is the code in the html file:
    <applet code="usblock.class" width="400" height="400">The browser doesn't support applets...</applet>The directory: www/usblock.html & www/usblock.java & www/usblock.class - As you can see the files are all in the same directory/folder.
    usblock.java code:
    import javax.swing.*;
    import java.awt.*;
    public class usblock extends JApplet
         public void init()
              JPanel p = new JPanel(new BorderLayout());
              p.add(new JLabel("Heisann"));
              add(p, BorderLayout.CENTER);
    }now as I open the html local on my computer, it workes. As soon as I open the usblock.html from my website, it doesn't.
    It gives me this error here:
    load: class usblock.class not found.
    java.lang.ClassNotFoundException: usblock.class
         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.IOException: open HTTP connection failed.
         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 moreSo I thought it was that it couldn't find the .class file. Well, I went through the How To add applets that I found somewhere on sun.com. It had exactly the same as I had.
    Im figuring the problem is something easy and not hard to detect. But my eyes can't find it somehow. This is my second time trying applets, and I kinda forgot how I got it to work the first time.
    Im just glad for all the help I can get.
    Thanks a lot.
    LordSvae
    PS: Sry for the size of the post, but I'm not sure how much info I was supposed to put in here, so I thought the more the better, right? :S

    Hii,
    I doesn't know the solution but same kind of problem is come with me & I found that the problem is of Path i.e. you need to set a codebase attribute . For tempory solution what i do i simply copy the .class file in to html file dir.

  • Simple Applet does not run in IE 5.0

    Hi,
    Am trying to run a simple applet in IE 5.0 on MS Window NT Server machine. I disabled the
    JVM option in Tools/Internet Options/Advanced/Java column. I have MS VM(Miscrosoft Virtual Machine) JIT(Just In Time Compiler) enabled. As a
    result any applet will run on the MS VM JIT only. I use a simple applet in which I just add
    a button to the applet. My applet runs fine in JVM Ver 1.4 but when I try to run it in MS VM
    using JIT I get the following exception
    Error loading class: ImageTest1
    java.lang.NoClassDefFoundError
    java.lang.ClassNotFoundException: ImageTest1
         at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
         at com/ms/vm/loader/URLClassLoader.loadClass (URLClassLoader.java)
         at com/ms/applet/AppletPanel.securedClassLoad (AppletPanel.java)
         at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
         at com/ms/applet/AppletPanel.processSentEvent (AppletPanel.java)
         at com/ms/applet/AppletPanel.run (AppletPanel.java)
         at java/lang/Thread.run (Thread.java)
    Can any one help me in solving the problem ? My applet source is
    import java.applet.*;
    import java.awt.*;
    public class ImageTest1 extends Applet
         public ImageTest1()
              System.out.println("On the Console !!!!");
         public void init()
              Button bt = new Button("Hello !!");
              this.setLayout(new FlowLayout());
              this.add(bt);     
    Thanks,
    Bala

    Take your HTML file and convert it with the HTMLConverter that comes with your JDK, this will create an <OBJECT> tag from the existing <APPLET> in the HTML file. With the newly created <OBJECT> tag, IE will know that it's supposed to run your applet with Java plugin (the only way for you to run an applet that uses swing.
    V.V.

  • Need help coding simple applet program

    Hello I'm attempting to learn applet programming in either swing or awt. Whichever is best for current applications. I want to begin by creating my first hello world application. I want to create a simple applet that has two buttons, press button number one and the text "hello world 1" comes up somewhere on the applet, press two and "hello world 2" comes up. can anyone help me with this simple applet? Thnx in advance

    http://java.sun.com/docs/books/tutorial/applet/

  • Cannot perform Bean lookup on signed Applet jar

    Hi All,
    I'm after developing an applet which runs from a number of jars on an Orion app server. Each one of these jars are signed and I can access the Applet okay. The problem is that I make remote reference to EJB's throughout the application. I cannot perform a Bean lookup on a signed jar. The only way it can be done is when the Client is granted all permissions. The client should pop up an option to grant permissions.

    If u are signing all the jar file along with the applet it should work
    It does work fine with me. my code given below
    note that i carry the following jar files along with my applet jar.
    orion.jar,ejb.jar,,jta.jar,jnet.jar,jsse.jar,jcert.jar,parser.jar
    and have them in my archive attribute of my html code for the applet
    also all these jars are signed
    hope this helps
    regards
    raees
    public void init()
         try
              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
              env.put(Context.PROVIDER_URL, "ormi://solomon:23791/helloApp");
              env.put("java.naming.security.principal", "admin");
              env.put("java.naming.security.credentials", "secret");
              Context ic = new InitialContext (env);
              HelloHome hello_home = (HelloHome)ic.lookup("HelloBean");
         Hello hello = hello_home.create ();
              System.out.println (hello.helloWorld ());
         }catch(Exception e)
              e.printStackTrace();

  • How to load an applet jar file?

    Hello everyone,
    I have an applet that uses my own jar file and approximately 6 third party jar files. I set up jar indexing (jar -i) which will download the jar files when they are needed. All seems to work well, but now I want to manually load the jar files which I cannot get working.
    When the applet starts, about 1/2 of the jar files are downloaded (because they are needed at startup). I then want to load the additional jar files in the background, after the gui is initialized. I have tried this using the below thread which is executed from within the applet's start method:
    // Try to load additional jar files in background by loading a class from each jar file.
    Thread loadClass = new Thread() {
      public void run() {
        System.out.println("Loading classes...");
        try {
          // Tried loading classes this way, doesn't work.
          getClass().getClassLoader().loadClass("pkg1.Class1");
          getClass().getClassLoader().loadClass("pkg2.Class2");
          getClass().getClassLoader().loadClass("pkg3.Class4");
          getClass().getClassLoader().loadClass("pkg4.Class4");
          /* Loading classes this way doesn't work either.
          Class.forName("pkg1.Class1");
          Class.forName("pkg2.Class2");
          Class.forName("pkg3.Class3");
          Class.forName("pkg4.Class4");
        catch(ClassNotFoundException e) {
          // First attempt to load a class (pkg1.Class1) throws exception.
          System.out.println("Can't find class: " + e.getMessage());
    loadClass.start();As you can see from above I am trying to load a class from each of the jar files so that the jar files would load into memory/cache. Unfortunately, it cannot find the classes. These are the errors from the java console:
    Loading classes...
    Loading: pkg1.Class1
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with no proxy
    Connecting http://my.server.com/my_dir/pkg1/Class1.class with cookie "JSESSIONID=some_big_long_char_list"
    Can't find class: pkg1.Class1
    So it appears the jar file is not being downloaded. When I take away the dynamic jar loading (removing the "jar -i" & adding them all to the applet archive list) the thread executes correctly. So I know the class names, etc, are correct. How does one load an applet jar file?
    Any help/suggestions are appreciated.

    The above error I posted was because I forgot to index the jar files. That is why it couldn't find the jar file. I thought I was getting farther along with my problem, but I apparently just forgot to index the jars. I am now getting the problem that I got yesterday...
    The applet freezes/hangs when it hits the thread. The GUI never opens (even though I'm running this thread right after the gui shows). The java console quits responding and the applet just stays the grey screen. I also tried the invoke later that you suggested.
    public void start() {
      // ...initialize gui...
      // Applet freezes and remains grey, also the java console freezes.
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          System.out.println("Loading classes...");
          try {
            // When I comment out the below forName calls, the thread will still run evidenced through the done print statement.
            Class.forName("pkg1.Class1");
         Class.forName("pkg2.Class2");
         Class.forName("pkg3.Class3");
         Class.forName("pkg4.Class4");
            System.out.println("...Done loading classes");
          catch(Exception e)     {
            System.out.println("Can't find class: " + e.getMessage());
    }

  • Loading images inside applet JAR

    Hi
    This is my issue: I have an applet which contains images inside the applet JAR. I want to display these images in my applet, but apparently due to browser access restrictions, I'm not allowed.
    My first code was like this:
    //security restrictions on browsers do not allow getResource
    ImageIO.read(MyClass.class.getResource("imgs/img.png"));
    //getResourceAsStream should be allowed by browsers
    ImageIO.read(MyClass.class.getResourceAsStream("imgs/img.png"));Both lines work when I execute the applet locally (command line / programming IDE), but when I deploy it to my web server, the resource "imgs/img.png" becomes a relative URL to my web application context (like /webcontext/MyClass/imgs/img.png). It works locally because the call to getResource returns a URL object with "file:" protocol, but I need it to look for my images bundled inside the JAR, not web hosted images.
    I need to avoid making the applet look for these images as a web resource... how can I do it?
    Thanks!

    dev@java wrote:
    warnerja wrote:
    I'm not convinced the code you posted wouldn't work, but since this is an applet, you have access to the Applet class. Check out the Applet.getImage method in conjunction with Applet.getCodeBase.
    [http://java.sun.com/javase/6/docs/api/java/applet/Applet.html]
    getCodeBase returns my web context, like http://myhost.com/mycontext/ , so it is pretty much the same as above.
    Thanks for your replyThat is the way to load resources though. Hence back to my earlier statement about not being convinced it would not work, with this addition: It should work, assuming you actually do have the resources properly located with the web app, whether they be in a jar, or loose files relative to where the web app is. My guess at this point is that they are not.

  • Where is the Applet JAR file?

    When an Applet (the JAR) is downloaded to the local PC, exactly where (the directory) we can locate the Applet JAR file? Is the file managed by the Internet browser?

    This has got to be browser-specific.
    You shouldn't write code that depends on this kind of information anyway.

  • Simple Applet not running in ie 5

    Hi I have built a simple applet consisting of 4 classes, The button panel, and three listener classes. When I run this from the command line it works fine, and presents me with a grey panel (100 * 180) and the three buttons are drawn onto the applet all of which work fine. But when I use the plug in html page I get a grey panel with a red 'X' in the top left hand corner! Do I have to upload all of this before I can even test it, or is it just a dumb typo??
    Here is the HTML plug in:
    <html>
    <head>
    <title>Button Applet</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <applet CODE="Buttons.class" CODEBASE = "Sun">
    </applet>
    </body>
    </html>

    Change your html file to look like this:
    <applet CODE="Buttons.class" CODEBASE = ".">
    Put the html file in the same directory as the one with the Buttons.class and try it again.
    ;o)
    V.V.

  • Simple X-fi Question, Please Help

    !Simple X-fi Question, Please HelpL I've been looking for an external sound card that is similar to the 2002 Creative Extigy and think I may found it in the Creative X-Fi. I have some questions about the X-fi though. Can the X-fi:
    1. Input sound from an optical port
    2. Output that sound to 5. surround- Front, surround, center/sub
    3. Is the X-Fi stand-alone, external, and powered by a USB or a wall outlet (you do not need a computer hooked up to it)
    Basically I want to connect a TosLink optical cable from my Xbox to the X-Fi. That will deli'ver the sound to the X-Fi. Then I want that sound to go to a 5. headset that is connected to the X-fi via 5. front, surround, and center/sub wires. The X-Fi has to be stand-alone and cannot be connected to a PC to do this.
    Thank you for your help.

    The connector must match, and the connector polarity (plus and minus voltage) must match.  Sorry, I don't know if the positive voltage goes on the inside of the connector or the outside.    Any wattage of 12 or more should be adequate.
    Message Edited by toomanydonuts on 01-10-2008 01:29 AM

Maybe you are looking for

  • Error is my code please help

    I have created a try-catch statement, I have also created a home made Invalid value exception class. I have also thrown the InvalidValueException in a calculate method in a seperate class. I am getting the error of unreachable catch block. Here is my

  • In Finder, can the "Return" key act as "Open" instead of "Rename" ?

    In Mail the "Return" key act as "Open" In iTunes "Return" act as "Play" But in Finder "Return" act as "Rename" instead of "Open" ? Can we make "Return" act as "Open" ? Thanks

  • Steps to create a flashlight app

    I would like to create an Iphone app that includes a flashlight within it. Any help?

  • Why does Siri stop working, or become unavailable?

    The topic says it all. Why is it that sometimes, even in a 4G area, Siri suddenly doesn't  work?

  • Deleting an activity

    Hi, I did an import of an empty development configuration. Then I create a new Java DC abc/mytest with the wizzard and new activity named TestActivity. Now there is an open activity with some default created files inside. After that I revert and dele