Images in jar file, Please help!!

Hello,
This is my code, I am trying to add images to buttons in ToolBar. The code along with images works if I say "java ABC", but dont work(images dont appear) when I jar the files. I have tried all the possible methods, Please help me.
          new2 = new JButton(new ImageIcon("images/new.gif"));
          /*try{
          ClassLoader loader=getClass().getClassLoader();
          URL fileLocation=loader.getResource("./images/new.gif");
          Image img=Toolkit.getDefaultToolkit().getImage(fileLocation);
          new2 = new JButton(new ImageIcon(img));
          }catch(Exception e) { e.printStackTrace(); }*/
          //new2 = new JButton(new ImageIcon(ClassLoader.getSystemResource("images/new.gif")));
          //new2 = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().getImage(getClass().getResource("./images/new.gif"))));
          //ImageIcon oo = new ImageIcon();
          //new2 = new JButton(oo.setImage(getClass().getResource("images/new.gif")));
               new2.setToolTipText("New");
Thanks
James

Hello,
The code is too big to post, I am adding the code that is required to get changed, please see it
          open2 = new JButton(new ImageIcon("images/open.gif"));
               open2.setToolTipText("Open");
               open2.addActionListener(this);
               open2.addMouseListener(new MouseAdapter()
                    public void mouseEntered(MouseEvent me)
                         status.setText("Opens a file");
                    public void mouseExited(MouseEvent me)
                         status.setText("open");
Thanks
James

Similar Messages

  • Executabe Jar File: Please Help

    Here is the problem. I had no problem before creating and running executable jar files at work or at home. I write the manifest file and then run "jar cmf mymanifestfile jarfile.jar *.class" and everything is fine. Both my work and home computer were set up to execute jar files, so all I had to do was click on the option.
    Now here is the problem. At work, they just installed PKZIP and now that is default for opening jar files. I still want it to execute the jar file though, so last night, when I went home, I right clicked on a jar file I had, clicked on properties, and saw that where it said "Open With" I had javaw. Sooo.. today, I come back to work, right click on a jar file here, and then where it says "Open With" I change it to "javaw" but now when I click on the file, it gives me a Java Virtual Machine error saying it can not find the main file. I am positive that this jar file was created correctly. Furthermore, if I go to the DOS prompt and run it using "java -jar jarFile.jar" it runs just fine (If I do "javaw jarFile.jar", it does NOT work).
    So my question is this: what do I need to set the "Open With" program to for executing jar files. Is there a way to do command line parameters so I can open with "java -jar". Please help.
    Any help would be very appreciated.

    Also, another thing that is weird is this.
    The old jar files that I created at home, run fine at home (execute when I double click them), and if you look at the properties they are run with "javaw", but, the new jar files I create, that I create exactly the same way as the ones I created before, dont work when I double click them.

  • .jar files Please help

    Good day all.
    I am very new to java and admittedly not a very technologically savvy person. However, I play the card game "Magic: The Gathering"? and wish to play online because not any of my friends play. I use a macintosh computer. I researched Magic Online and found you could download a free trial from Wizards of the Coast Website, but it was not for Macs. I continued to research and found something called "WebWizard" a program allowing Mac users to play Magic Online. I downloaded the necessary files and attempted to install them. The two files were named 'ww.jar' and 'cards.jar'. When I opened 'ww.jar' it said "Jar Launcher: The jar file "ww.jar" couldn't be launched. Check the Console for possible error messages". I opened 'cards.jar' and received the same message. Using what little intelligence I have in regard to Java, I opened a search for anything related to it, and found the Java Web Start application. I started up the application and followed the instructions, and was asked to locate the files I wanted to view. I located the first, 'ww.jar', and it opened a page full of what I assume was programming language that had been translated into what the symbols would be on my computer - Total gibberish. I opened the 'ww.jar' once again and the error message did not appear. Instead, the WebWizard window started up!
    However, I needed to get the 'cards.jar' file to work so I could start playing Magic Online. I tried to do the same thing with Java Web Start, but 'cards.jar' failed to open when I located it. I tried opening the file anyways, but nothing happened.
    I have worked for about an hour on trying to get this to work, and have not found any way. Please help me out!

    If you just want to play casually, you can use Magic Workstation. It's free, but it won't let you play with other people on Magic Online, but I think it does have some tournaments of its own (but not for prizes). Another older piece of software that isn't used as much anymore is Apprentice. I don't know if either of these run on a Mac.
    Depending on what version of Mac you're using (and if you have a PowerPC processor), you might be able to use Virtual PC (which costs money) to install a Windows image on your computer, and then virtually run Magic Online (if you obtain the Windows image from a file sharing network instead of purchasing Windows legitimately, this is illegal).
    You could also try using VMware Player (which is free software) to run Windows virtually on your computer and play Magic Online that way. I'm not sure if VMware runs on a Mac though.
    Please don't try all of these things until something works; this will be very time consuming. Give us some more background on where the Jar files came from and, if you can, the error messages printed to the Java console. Also, how much do you know about computers? If you know how to compile source code that will probably increase your options since I believe the source code for VMWare Player is available.

  • I am new with JAR files please help me

    Hi Dear All,
    I am new with JAR files, I know concept, but dont know how to careate JAR, and how do i use it?
    Please help me.
    Thanks

    This tutorial covers that:
    http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

  • URLClassLoader - with JAR Files- - - Please Help

    Hi all,
    I have two seperate JAR files which contain same files but different progressive versions.JAR 1 is version V1 and JAR 2 is Version V1.1
    I have a program which loads classes from these two JARS and runs certain comparsions on them.CODE IS SHOWN and SO is ERROR.PLEASE HELP and ADVISE.Im on a UNix box using JDK 1.3.
    CODE:
    ====
    1.In my main i define the TWO JARS PATHS and the item to compare called ENTITYNAME as:
    String jarFile1 = "/xenv/GFINet_Java/6.2_Z1/1.3.X/gfinet_entities.jar";
    String jarFile2 = "/xenv/GFINet_Java/6.1_Y1/1.3.X/gfinet_entities.jar";
    String entityName = "gfinet.entities.GFIBasketEntity";
    2.Then i call the function
    EntityVersionComparator evc = new EntityVersionComparator();
    evc.test(jarFile1, jarFile2, entityName);
    3.Test function loads the JARS
    private void test(String jarFile1, String jarFile2, String entityName) throws Exception {
    URLClassLoader jar1 =
    (URLClassLoader)newClassLoader(jarFile1);
    URLClassLoader jar2 =
    (URLClassLoader)newClassLoader(jarFile2);
    4. Load that item ENTITYNAME FROM JAR.
    // load GFIBasketEntity from Jar1
    GFIBaseEntity ent1 =
         (GFIBaseEntity)loadClass(jar1, entityName).newInstance();
    PROBLEM ERRORS:
    ==============
    Exception in thread "main" java.net.MalformedURLException : no
    protocol :/xenv/GFINet_Java/sun4/6.2.Z2/Solaris8/3.3.2/1.3.X/lib/gfinet_entities.jar
    at java.net.URL.<init>(URL.java:473)
    at java.net.URL.<init>(URL.java:376)
    at java.net.URL.<init>(URL.java:330)
    at EntityVersionComparator.newClassLoader(EntityVersionComparator.java:143)
    at EntityVersionComparator.test(EntityVersionComparator.java:88)
    at EntityVersionComparator.main(EntityVersionComparator.java:74)
    WHATS GOING ON..Is there something wrong with the path?Pls advise
    jason

    I also in my CODE have:
    private ClassLoader newClassLoader(String path)
    throws MalformedURLException
    { URL url = new URL(path);
    return new URLClassLoader(new URL[]url);

  • .jar File please help

    Hello,
    suppose I have three .jar files: file1.jar, file2.jar and file3.jar.
    these file are in the folder c:\folder.
    how can i specify all this files in my classpath without specifying them one by one. now i'm doing it like:
    classpath=c\folder\file1.jar;c:\folder\file2.jar;c:\folder\file3.jar
    I will like to do this at once
    can someone help me please?
    thanks.

    If u mean that u want only one jar file must be added to classpath, then extract file1.jar, file2.jar and file3.jar to some path (say myFolder). Then, zip the contents of myFolder (don't zip myfolder as well!) into one jar file (zip creates a .zip file - rename it as a .jar file). So, u have one jar file with the contents of 3 jar files. But I seriously don't see why u want to do this. The semicolon terminated way of adding jars would work just as well right?

  • Executable Jar file, please help!!!

    I know this has been posted many times before, but Im going insane, and nothing is working, I will now have spent more time trying to make an executable jar file, than the time I spent actually writing the program, here's my problem
    I got two classes, tictactoe.class, and whichBox.class, I want to make a jar file, I have tried many types of manifest files, none worked, my Main() is in tictactoe.class, if ANYONE can help me get this working I will give them dukes!!!!!

    I know this has been posted many times before, but Im
    going insane, and nothing is working, I will now have
    spent more time trying to make an executable jar file,
    than the time I spent actually writing the program,
    here's my problem
    I got two classes, tictactoe.class, and
    whichBox.class, I want to make a jar file, I have
    tried many types of manifest files, none worked, my
    Main() is in tictactoe.class, if ANYONE can help me
    get this working I will give them dukes!!!!!
    your manifest file should look like this...
    Manifest-Version: 1.0
    Main-Class: tictactoeplease note there must be a line return at the end of tictactoe. so the file should have three lines.
    if you have this correct the only other thing i can suggest is are you sure it is your manifest file that is being added to the jar.
    your jar command should look like the following assuming the jar files is called Game, your manifest is called game.mf and both files reside in the default package.
    jar -cvfm Game.jar game.mf *.class hope this helps.

  • Problem with jar file please help!!

    Hi everybody
    I make a jar file using Jbuilder;my application interact with oracle and when i try to run it ,I get the following message:
    "no driver was found "
    however i add the oracle driver in my jar file as a library dependencies.
    could some one help

    I don't know whether this will help you or not.
    You have mentioned that drivers are added into jar file which you have created. Similar situation I faced. In my case I added classes12.zip for ORACLE thin drivers. For this to work I had to set classpath for this zip file. Once I set the classpath for this zip file my application started working fine.
    So if you are using any zip or jar file for your driver you will have to define it in your classpath.
    Mushy

  • Hello- I am a Canon photographer.  I use Bridge (CS5) to process my raw files to jpegs.  I am taking on a second photographer who shoots Nikon (D800) and i am not currenty able to see or process his images.  Can you please help?  thankyou!

    Hello- I am a Canon photographer.  I use Bridge (CS5) to process my raw files to jpegs.  I am taking on a second photographer who shoots Nikon (D800) and i am not currently able to see or process his images.  Can you please help?  thank you!

    According to Adobe:
    D800
    NEF
    6.7, 7.1
    4.1
    D800E
    NEF
    6.7, 7.1
    4.1
    The fact that they have 2 versions of ACR means that initial support for the D800 was added in 6.7  but that complete support was finalized in 7.1 (the 4.1 in the chart is for Lightroom)
    I'm not sure that this means there are missing features, but rather refinements and optimized settings were added in 7.1
    However, ACR 7.1 requires CS6.
    As Dag mentioned, you can also use the latest version of DNG Converter to convert the D800 files to DNGs which will be able to be opened in older versions of ACR.
    The DNG converter only works on folders of files, not individual files. So just select the folder and convert. All the files in the folder will be converted.

  • Problem loading image from jar file referenced by jar file

    First, I searched this one and no, I didn't find an answer. Loading images from jar files has been pretty much done to death but my problem is different. Please read on.
    I have my application, a straight up executable running from Eclipse. It uses a jar file, call it JarA. JarA launches a GUI that is located in another jar file. Call it JarB. To recap:
    My application calls JarA -> JarA loads classes from JarB -> JarB looks for images to place in a GUI it wants to show on the screen
    When JarB goes to load an image the following happens:
    java.lang.NullPointerException
         at sun.misc.URLClassPath$3.run(URLClassPath.java:316)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:313)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:290)
         at sun.misc.URLClassPath.findResource(URLClassPath.java:141)
         at java.net.URLClassLoader$2.run(URLClassLoader.java:362)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findResource(URLClassLoader.java:359)
         at java.lang.ClassLoader.getResource(ClassLoader.java:977)
         at org.cubrc.gmshell.gui.MainWin.preInit(MainWin.java:152)
         at org.cubrc.gmshell.gui.MainWin.<init>(MainWin.java:135)
    The code from JarB that loads the image looks like this:
              URL[] oSearch = {Main.class.getResource("images/")};
              URLClassLoader oLoader = new URLClassLoader(oSearch);
              imgIcon = new ImageIcon(oLoader.getResource("icon.gif"));
              imgMatchRunning = new ImageIcon(oLoader.getResource("gears.gif"));
              imgMatchStill = new ImageIcon(oLoader.getResource("gears-still.gif"));
              imgMagnify = new ImageIcon(oLoader.getResource("magnify.gif"));This looks right to me and JarB certainly has an images directory with those files. But I'm in hell right now because I don't know where to place the images to make this work or if you can even attempt to load images with a dependency chain like this.
    Any help very appreciated!

    Have you tried to move your image-files out of the jar file and place them in the sam folder as the jar-file? I think that would help.
    When you try to load the image-file you get the NullPointerException because the program tries to read a file it can't find. Remember that a jar file IS a file and not a directory.
    If you want to read somthing inside the jar-file you need to encode it first.
    Have you tried to read the jar-file with winRar. It makes it easy to add and remove files in your jar-file.

  • HOW TO - Create new from clipboard and process multiple files - please help

    Need help - have new version of photoshop on trial only ATM...
    Want to know - HOW TO:
    1. Create new from clipbaord
    2. Process multiple files
    Please help.

    For clipboard copy, I start with File > New and the size will be set to what's in the clipboard. Then once the new file is opened, Edit > Paste will place the clipboard contents as a layer in the new document.
    You must remember to use the command Layer > Flatten Image of you want to save as jpeg or any other file format that doesn't support layers.
    For processing multiple files,
    File > Automate > Batch or
    File > Scripts > Image Processor...
    Check the User guide or google information for those commands if you have specific needs.
    Gene

  • I'm getting this problem when trying to update my iphone 3gs it says that the iphone software could not be contacted and I went on youtube got some advise to go into my hard drive to fix the error I have nothing in my host file please help me if you can

    I'm getting this problem when trying to update my iphone 3gs it says that the iphone software could not be contacted and I went on youtube got some advise to go into my hard drive to fix the error I have nothing in my host file please help me if you can this is all new to me.

    Read this: iOS 4: Updating your device to iOS 5 or later
    ... oh I think it is a 3gs or a 3
    This makes a difference. What does it say in Settings > General > About?

  • Applet : How to use Images in Jar file

    I want to put all images into a jar file to improve speed of loading.
    But how to invoke images from Jar file?
    Thanks.

    @Op. It's very important for a developer to know how to find information, and that skill usually comes with experience. Google is one of the best ways to find information and solutions to the most common problems.
    Kaj

  • Add images in jar file

    how to add images in jar file?

    Check this article in ADF code corner:
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/86-images-from-jar-427953.pdf
    Thanks,
    Navaneeth

  • Illustrator CS4 wont save files, please help?

    You can edit a file, go to save, close it down, then when you re-open it the changes made have not been saved?? No error message or warning pops up, and it all looks ok like it has saved properly, until you open it up again. This also happens when you use 'save as' command if you use the original file name. If however you type in a different file name - it saves ok. But obviously that is not great as you cant now trust or rely on the save mechanism of the programme, to make sure any changes to artwork have been stored!! I have never seen an issue like this, it is worrying, I hope somebody can help?
    Thanks.
    We are running CS4 on windows7 - yes PC!!!

    We save in EPS, and its not just one file, its a variety of different files and it seems to be random as to which files it does it on, some work fine - some don't. And it can be anything from a minor text change to a colour change, it doesnt seem to matter on the change made, it reacts the same.
    The files are saved over a network connection to a large external hard drive.
    Its really puzzling and now starting to cause problems as we do a fair bit of work in it, and can't trust one of the most important features, and that any changes that have been done have been saved and stored!
    Hope maybe you can help with any thoughts at all.
    Cheers.
    Date: Thu, 24 Jun 2010 03:41:40 -0600
    From: [email protected]
    To: [email protected]
    Subject: Illustrator CS4 wont save files, please help?
    What file format do you save it in?
    What kinds of changes did you make in that file?
    Where do you save the file (removable or network media)?
    >

Maybe you are looking for