Accessing files in a JAR from an Applet

I've been stuck trying to get my applet to work online. The applet and its inner classes, as well as a folder with a bunch of text files it needs to run, are all in a jar file (on a geocities website =/ just trying to get it working). My html code for the applet looks like this:
<applet code=Graph.class archive="Grapher.jar" height="600" width="1000">
</applet>
Graph is the class that runs the applet, and it has some inner classes for buttons and a drawing pane. When I try to run the applet online, I get this error:
java.lang.NoClassDefFoundError: Graph$MyDrawPanel
     at java.lang.Class.getDeclaredConstructors0(Native Method)
     at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
     at java.lang.Class.getConstructor0(Unknown Source)
     at java.lang.Class.newInstance0(Unknown Source)
     at java.lang.Class.newInstance(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)
I know that Graph$MyDrawPanel is in the jar, and the applet works in NetBeans, what can i do to make firefox look inside the jar to find my inner classes?

Try this:
<applet code="InteractiveGrapher.Graph.class" codebase="." archive="monarchive.jar" width="1000" heigth="600">
</applet>See http://java.sun.com/j2se/1.5.0/docs/guide/jar/jarGuide.html
See also the example in the java tutorial
http://java.sun.com/docs/books/tutorial/deployment/applet/browser.html
(See the code source of the web page)
hth,
Message was edited by:
java_2006

Similar Messages

  • How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant.  The files show up on the new MacBook but cannot be opened.  Thanks!

    How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant?  The files show up on the new MacBook but cannot be opened.  Thanks!

    Get info then check permissions then add your curent user name (it was probably different on old Mac) and give your username full read/write permissions.

  • Creating a JAR in Eclipse...can't access files in the JAR properly.

    Hi all! I'm a newbie at JAR creation, and am having troubles. I have a project that loads images from image files in my project. I can create the JAR and all, and it runs, but the buttons that have ImageIcons with those IO loaded images are blank. I've tried to include the images when creating the JAR, but it keeps acting like the images never existed. When I run the JAR and have the images separately included in the directory (instead of packing them up too), it won't work as well...UNLESS those images are put in my $HOME directory (Linux).
    Does anyone know how I can properly refer to the images that I'm trying to pack into the JAR from within the JAR? Or, is there a way for the JAR to understand where those images are supposed to be (redirect the focus from the $HOME directory to the JAR's directory)? Any help would be greatly appreciated! :)
    -Keith

    Hi,
    Can the user execute the program through explorer? In Windows Server 2003, the Users group does not have Read and Execute permissions to the command processor (Cmd.exe). 
    You could refer to the article below to resolve the issue:
    "Access is denied" error message when you run a batch job on a Windows Server 2003-based computer
    http://support.microsoft.com/kb/867466
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to protect my files in a jar from extraction

    I want to protect my jar files (using a password )from extraction.
    When a user wants to extract, password must be asked alike password protection in a zip file.
    Can i do it using java itself or i need a external tool.
    Thanx

    i am trying to find it out

  • How do I access files on my Macbook from my iMac?

    I'm about four months new to my Macbook and I'd like to access just files on my Macbook from my husband's iMac. We have wi-fi in the house.
    Thanks!

    Start by going to > Mac 101: File Sharing

  • Access files on Time Capsule from remote Windows computer

    Is there a way to access files on my Time Capsule at home from a different computer? I often need to get files from my mac at school - which has only Windows computers - and since I have a MacBook that is shut when I’m not using it, the best way would probably be to access the Time Capsule, that is always on and available. I always have a flash drive, so if I need any files or apps I could just add them there, or to my user account at school. I can’t change any settings on the router it is connected to, but I can change any settings required on the Time Capsule. The Time Capsule is set to connect to our wireless network. I have tried to google this, but I couldn't find anything. Any ideas?

    Isn't it just to turn on static ip in the Time Capsule preferences? As I said, I can change any preferences on the Time Capsule that I have to.
    The static IP I am talking about is not private but public.. ie the address the ISP gives you.. unless you pay extra or your ISP has more brains than most.. any IP assigned to you is rotated on an hourly, or daily basis usually. This is to prevent you using using your network as a server on the internet. At least not without paying them more money.. and it helps when you do bad things.. and get banned from a site.. with a static IP that ban is forever.
    So Problem 1.
    From the internet your address keeps moving around.. how are you going to find it.
    Problem 2.
    Time capsule does not offer a windows protocol to the internet. Only AFP.. apple file protocol.. windows cannot talk AFP. The Time capsule does not offer any other protocol except AFP and SMB (windows networking).. and only AFP is offered to WAN. SMB is so unsafe if ISP opened the port the world would be flooded with hackers. Because so many windows computers have so little protection.
    Solution.. use a Mac. This is apple world.. when you buy one.. you are forced to buy more. There is a reason TC does not offer dyndns client and ftp etc. That would mean you could access it without a Mac and buying iCloud account.. with a Mac and iCloud you can do it easily. Surrender.. they have you on a noose.. struggling just tightens the knots.
    Solution.. use dropbox and keep the files you want on the internet.
    Solution .. as already mentioned.. replace the TC as the main router.. use it as a file store and get vpn router with dyndns client.

  • Can't access files on my ipod from itunes

    Anyone you understand??
    I can't anymore access my files on my ipod from itunes. I can see what is there, but it won't allow me to delete any files on my ipod.
    At start up, it does the syncronicing, finish in itunes but the display on my ipod never go beyond "do not disconnect". It won't allow me to close/remove the ipod from itunes - error message - some files are in use, can't close down ipod.

    if you sync iPod, you can NOT delete music, podcasts, TV shows or videos in the iPod itself. if you want to delete it from the iPod, either delete it from iTunes and at the next syncing, the file will disappear.
    Sometimes you also simply have to click a second time on the "eject" button after getting the warning that "some files in use".

  • How to access files in a jar file?

    Can anyone tell me how to access a file contained in my jar file?
    I have about 15 classes jarred and deployed as an applet. I want to include in the jar file some .gif files to be used as icons in a tree view. Rather than trying to access them locally with all the security headaches this brings, can I not simply jar them as resources and point to them in my code?
    Any help much appreciated,
    Thanks in advance,
    Chris

    Hello Chris,
    Please read this note taken directly from Sun, from their Java Tutorial/Creating a GUI with Swing/Using Other Swing Features/How to use Icons/Specifying the Image Source (whew!)
    Note:  Applets are supposed to be able to load images from JAR files.
    Currently, however, some browsers can't read images from a JAR file,
    although they do successfully get classes from a JAR file.
    With our applets, we currently hedge our bets by both putting
    the image files in the applet's archive file (the JAR file containing
    the applet's class files) and by putting the image files in the file
    system on the server.
    */So......Do you want to take a chance?
    -Ron

  • Build a .jar from an applet

    Hi. I have the following code.
    import controller.Application;
    import model.Slideshow;
    import view.MainFrame;
    import java.applet.Applet;
    public class Main extends Applet {
        public void init() {
            Slideshow slideshow = new Slideshow("untitled.xml");
            Application app = new Application(slideshow);
            new MainFrame(app);
    }I can create the .jar file but when I open it a message of "couldn't finde main class" appears... obviously... it's an applet ! how can I create an excecutable file? thanks very much

    Akcents wrote:
    public class Main{
    public static void main(String[] args) {
    Slideshow slideshow = new Slideshow("untitled.xml");
    Application app = new Application(slideshow);
    new MainFrame(app);
    how can I make an executable file with this class????
    This question is quite different from your original question. Is it your intent to convert the application into an applet or are you interested in creating an [executable JAR file|http://java.sun.com/javase/6/docs/technotes/guides/jar/jarGuide.html]? If it's the latter, when bundling your application in a JAR file you'll need to update the [JAR file manifest|http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html] with a Main-Class entry. If it's the former, the following link will be helpful:
    [http://java.sun.com/docs/books/tutorial/deployment/applet/getStarted.html |http://java.sun.com/docs/books/tutorial/deployment/applet/getStarted.html ]

  • Accessing files outside the jar

    Greetings,
    I've got a jar file with some classes, which is in a directory. In this dir there are also some resources. How to access those resources from inside the jar?
    Thanks in advance,
    imaginner

    Try this...
    In your class, add this line...
    String path = System.getProperty("user.dir");
    it will give the path of the folder from which you are running
    your jar file. To this path, add your properties file name
    and start reading it.....
    For example:
    If i have a properties file which both :
    1) should be able to read and edit by users and
    2) should be accessible by classes in jar file....
    I would use the above concept like this.... in my class.....
    String path = System.getProperty("user.dir");
    Properties props = new Properties();
    props.load(new FileInputStream(path+"yourPropertiesFileName"));
    Hope it helps...
    Vijay

  • Access files on mac-mini from external hard drives hooked to PC...

    Have two external hard drives hooked up to my PC. I am in the process of daisy-chaining (via firewire cable) from the one external-Hrd-Drv (only one that has firewire input) to my MAC-MINI. APPLE STORE REP says it will pick up BOTH hard dirves (through a "daisy-chain" -like cycle) and that their icons will just pop-up on my mac-mini. So, it's all hooked up and then I clicked over to the mac-mini and there's NOTHING. Both hard-drive icons are no where to be found! There still ONLY found on my PC, of course. Once a again, I was told that my mac-mini would pick-up or access both hard drives from my PC by JUST using a firewire cable! I've done that and I'm having no such luck. Is there a way to do this? Please Help...thanks!

    Can you re-state exactly what drives are connected to which computers, and how?
    An external hard drive plugged into a PC (or, indeed, even another Mac) on your network will not automatically "show up" on your Mac mini, no matter whether it's USB, Firewire or what. The only way you can even connect to it from the Mini would be to share it out from the PC as an SMB/CIFS (Windows file sharing) share across the network.
    Matt

  • How to access files outside a .jar file netbeans project

    Hi, i need to access a file outside a built project inside netbeans. Ideally i would like this file next to the .jar file as myapp.properties. If possible i would like it so that when i am compiling and running the project in netbeans the file can be with the class files or something along those likes. Either way it would be nice to have different code for built projects and just running them outside a jar.
    Heres what i got so far
    properties = new Properties();
                InputStream in = this.getClass().getResourceAsStream("applications.properties");
                properties.load(in);
                in.close();this only works if the file is next to the classes. (think thats called the classpath ? )
    Thanks for any replies!!

    Your wrong code:
    properties = new Properties();
    InputStream in
    = this.getClass().getResourceAsStream("applications.properties");
    properties.load(in);
    in.close();A right code:
    // basic assumption 1: applications.properties
    //  is a pure ISO 8859-1 text file
    // basic assumption 2: the file applications.properties
    //  is stored in the same directory where your
    //  jar file is stored
    properties = new Properties();
    try{
      FileInputStream in      // assume current dir
       = new FileInputStream("applications.properties");
      properties.load(in);
      in.close();
    catch (Exception e){
      e.printStackTrace();
    }

  • Will someone make a quick way to access files in the cloud from Photoshop?

    I know you can access your shared files in your browser, and in a browser, but it would be so much easier to see shared files in another tab, similar to the libraries tab.
    m

    OK, thanks for the advice, Erik. I was hoping not to have to use the zoom sliders or the stretch scrollbars method, since it's not as fast as a one-click or double-click method.
    One other possibility I was investigating today was saving a screenshot and then recalling it. The manual says:
    Saving and Recalling Screensets
    Screensets are numbered from 1 to 99 (using only the 1 to 9 computer keys—the 0 key
    is assigned to the Stop command by default).
    You don’t need to save screensets with an explicit command. It happens automatically,
    as soon as you switch to another screenset. Thus, without any effort, your current
    working view is always stored as the current screenset.
    To create a screenset:
    1 Press a numerical key, say 7.
    For two-digit screensets, hold down Control while entering the first digit.
    2 Arrange your windows as desired, including changes to zoom settings, relationship of
    the Arrange area and editor areas, open or closed Inspector and Media or Lists areas,
    and so on.
    To recall, or switch between screensets, do one of the following:
    m Input the number of the desired screenset (1 to 9).
    I thought that had real possibilities. Make the arrange window the size of my whole project to begin with, then save it as, say, screenset 3. Then if I zoom in on a wave form or change the size of everything, just recall screenset 3 to get back. Unfortunately, it apparently constantly keeps track of all your changes, so if you zoom within screenset 3 and then try to recall the screenset 3 that you saved, it just takes you to where you are currently, after all the zooming. I don't understand why Logic thinks that helps you, but that's how it seems to work.
    Anyway, I've spent enough time on it. I give up. I guess I will use control-left-arrow, control-right-arrow. Unfortunately, you cannot do them both at the same time, it seems, which would be faster. Oh, well.

  • HT2518 not able to access files on macbook air from windows pc

    Dear All,
    I have resorted to all the options. I want to access macfiles from windows PC. I trieds out all the options. I went to system preferences> selected "file sharing">selected the folder>selected the user name and password for windows account.
    But when i click the macbook on the network from windows pc, it prompts me to enter user name and password. When i do the needful it says denied access. I tried to access macbook from two different windows PC one running XP and the other windows 7. The funny thing is that this access is sometimes allowed "say 10% of the time" using the user name and password and sometimes its not allowed.
    Another interesting thing is that i am able to connect to windows PC from Macbook but not the reverse option. Somebody pl suggest a way out.
    Regards
    KMurthi

    i have done all that. Both the systems are in the same "WORKGROUP" folders.
    The peculiar thing is smtms i am able to access the contents of shared folder of Mac but most of the time after i enter d username n passwd the screen just gives the message connecting to......Can this be due to communication issues b/w Mac and windows operating systems. Anyways i am facing lot of problems because of this..Interestingly i can access windows folders easily through MACA system by clicking "GO" and then "CONNECT TO SERVER" path....
    Pl let me knw if anyone has any clue on how to sort this issue.
    Thanks for the earlier message

  • Accessing Files within a jar - Problems.

    So i have the following code in my program and when i goto run the jar file i get NPE's:
    URL fileURL = getClass().getResource("resources/cfg/portlist");
                    BufferedReader portFileBuff = new BufferedReader(new InputStreamReader(fileURL.openStream()));Now my jar file has resources/cfg/portlist in it and i cannot figure out why this isnt working for me when it works just fine in another program i have. I feel im missing out on some framing issue. Any Suggestions?

    Hello,
    I have the same problem when trying to log "log4j" from a jar....
    Here is my code that generate the error:
    static{
              DOMConfigurator.configure("config"+File.separator+"log4j.xml");
    Obviously, the file log4j is in my jar in the directory config.
    This code works well outside the jar.
    It semms that I got also the same problem on library that are in my jar under the directory "lib"....
    Any idea..?

Maybe you are looking for