Jpg in a jar

im sorry but you probably had this question i tried too figure it out help please!!! i put my jpg's in my jar file but they dont appear when i execute the jar can anyone tell me how to make them appear my jpeg is an ImagIcon called brush.jpg i know that i have too use .getResource() but it doesnt work i know that i'm making a simple mistake i get an ';' needed error but cant figure it out

try this:
ImageIcon ii = new ImageIcon(ClassLoader.getSystemResource("brush.jpg"));

Similar Messages

  • How to display a .jpg in a JAR file

    I wrote a programe"demo" to display a "001.jpg "
    and I made a demo.jar file
    D:\0816>jar -tf demo.jar
    META-INF/
    001.jpg
    Demo.class
    META-INF/MANIFEST.MF
    I notice that 001.jpg is in the the jar file
    but the demo.class can not display it. what can I do?
    ps:
    Manifest.MF
    Manifest-Version: 1.0
    Created-By: Ant 1.4.1
    Main-Class: Demo

    Here is a generic code snippet that you should be able to use.
    String myImageFile = "image.jpg";
    URL myURL;
    ImageProducer myImgProd;
    Image myImg;
    myURL = getClass.getResource(myImageFile);
    try {
        imgProd = (ImageProducer) myURL.getContent();
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    myImg = tool.createImage(myImgProd);

  • Storing images and icons in a JAR file

    Hi,
    I current have a JAR file to store our application icons in the GIF format. The application also uses several images which I would prefer to be stored in the JAR file as JPG files.
    Is it possible to store both GIFs and JPGs in a JAR and access them from Forms?
    For Example:
    I am using code like:
    read_image_file('mess_bold.jpg','URL','IM_BOLD');
    and I have this image file in the JAR but I get the error...
    Unable to load image mess_bold.jpg for Image Item
    Also the Apache log shows...
    File does not exist: c:/oracle/frhome_1/forms/java/icons/mess_bold.jpg.gif
    Is this a config problem? I noticed that the read_image_file call looks in the icons directory which I specify in my Registry.dat file. Do the settings for default.icons.iconpath and default.icons.iconextension apply to images as well?
    Thank you in anticipation.
    Regards,
    Tom Casserly

    Hi,
    I already had the entry imageBase=codebase in my formsweb.cfg
    According to this article it is possible to read images from the JAR using the 'URL' parameter see
    https://metalink.oracle.com/metalink/plsql/f?p=130:14:2109110130595761322::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,137397.1,1,1,1,helvetica
    I have managed to get the images loading from the JAR but only if I have them in the same directory and format (ie gif) as the icons. As I suggested above I think that read_image_file must be accessing the default.icons.iconpath=icons/ default.icons.iconextension=gif from my Registry.dat file.
    There is also a slight problem that you cannot seem to use read_image_file in the WNFI or PF trigger as suggested here: Re: Read images from a jar file?
    Has anyone managed to access images from a JAR in JPEG format alongside GIF icons?
    Thanks for you help.
    Regards,
    Tom Casserly

  • Problem change Graphics2D into jpg

    this is part of the code i have
    private void drawPawn(Graphics2D gr, Integer pawn, Color c) {
              Coordinate coord = parent.getGameCore().currentBoard().getCoordinate(
                        pawn);
              int y = coord.getLine();
              int x = coord.getRow();
    // Image Image1; <-------------------------this is first try
    // Toolkit toolkit = Toolkit.getDefaultToolkit();
    // Image1 = toolkit.getImage("kangaroo.jpg");
    // BufferedImage Image1 = null ; <--------------------------this is second try
    // try {
    // Image1 = ImageIO.read(new File("kangaroo.jpg"));
    // } catch (IOException e) {
    ImageIcon Image1 = new ImageIcon("kangaroo.jpg"); <--------------------------and last try but it doesnt work(cant view the jpg)
              gr.setColor(borderPawnsColor);
              gr.fillOval(horizontalBorder + x * slotWidth, verticalBorder + y
                        * slotHeight, pawnDiameter + pawnBorderSize, pawnDiameter
                        + pawnBorderSize);
              gr.setColor(c);
              gr.fillOval(horizontalBorder + x * slotWidth, verticalBorder + y
                        * slotHeight, pawnDiameter, pawnDiameter);
    gr.drawImage(Image1.getImage(), horizontalBorder + x * slotWidth, verticalBorder + y
                        * slotHeight, this); <--------------------------this is where the problem place
    ive try different ways to view "kangaroo.jpg".but it doesnt work.anyone could help me?
    i get this code from googling.

    forent wrote:
    sorry..when i change the root into "E:/My Documents/NetBeansProjects/Bordeaux/src/gui/kangaroo.jpg".but why this happen?
    it solve my problem.
    yeah it called from paintcomponent().
    thanks.. :-DThat is not the root of your project, it is a direct path to your JPG. IT happened bacause your code was correct, but your JPG is in the wrong place. Your project is in "E:/MY Documents/NetBeansProjects/Bordeaux", put your JPG in there and you can access it then by just the name "kangaroo.jpg", but if you JAR your file, then you'll have to loadresource and include the JPG in your JAR to get it to work that way. In any case a direct path to your JPG will work, but you lose the ability to move your JAR freely from machine to machine as a self contained unit able to run on any appropriate JVM--you will always be requred to have that hard path "E:/My Documents/NetBeansProjects/Bordeaux/src/gui/kangaroo.jpg" to your JPG and if your friends don't have an E drive, they are just out of luck.

  • External Jars in JSP Dynpage

    Hi,
    I have implemented reading an XML feed in a Java program using informa api.
    In NWDS, I created a Java Project. And as required added 3 externals jar files.
    I had to import the following:
    import de.nava.informa.core.ChannelIF;
    import de.nava.informa.core.ItemIF;
    import de.nava.informa.impl.basic.ChannelBuilder;
    import de.nava.informa.parsers.FeedParser;
    The program works on run.
    But when I creat a JSP DynPage and I add the follwoing lines:
    <%@ page import = "de.nava.informa.core.* "%>
    <%@ page import = "de.nava.informa.impl.basic.ChannelBuilder "%>
    <%@ page import = "de.nava.informa.parsers.FeedParser "%>
    I get an error: Error occurs during the rendering of jsp component. Even in this project I added external Jar files in the same way.
    Any particular stuff need to reside on the server or something?
    Because I one tried implementing JCO in JSPDynPage by adding the external jar in the project structure and it worked fine.

    Hi Prem,
    Probably the jars you must have added in your last project would be available on the server or they would have been some server related jar files.
    But in the case when you are inclusing some external jars, you need to inclusde it both as "<b>External Jar</b>" and also add it to the <b>lib</b> folder (ie: just copy and pate the jar files in the <b>lib</b> filder).
    <b><a href="http://img142.imageshack.us/img142/8168/solution4gy.jpg">Put the .jar file here</a></b>
    I hope this solves your problem.
    Regards
    Pravesh
    PS: Please consider rewarding points if helpful and solved.

  • Need signed applet to read a file in the jar?

    i have an applet and i need to read a file (just a picture .jpg) within the jar. but i got a security exception when i try to make the File object for this jpg
    thanks and sorry for my english

    Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResorce("FileName.jpg"));i need to make something like this
    File file = new File("picture.jpg");
    the idea is verify that picture.jpg is really the picture that i put and not other with the same name... and if it is a file objet i can see the last modification date, to make a validation...
    another way is to read some pixels and verify that its colors dont change... but i dont know how to do this neither.
    but thanks anyway!

  • Makeing a .jar file or .exe

    How can I make one of these. I read the tutorial but it doesn't make sense. Do I put the code into the program? Can I run the program on another computer by just taking the jar file on a disk. Can some one inform me and help me understand these compiling things.

    As far as jar files go, you put .class files and dependent data files into a jar. For example, you can put an .jpg into a jar. You can run the application on another computer by copying the jar file to the other computer, assuming you created the jar correctly and the other computer has a compatible JVM installed.
    As far as .exe files go, search the forums here using keyword .exe and you should be able to find some applications that create .exe files. Or try Google.

  • Jar file and image

    Hi, i have a problem with my desktop swing app. A splash screen i added at the start of application.
    I created a exe file form jar, and There is a image file(jpg) on splash. In netbeans i put image in a images
    folder ( src, images, build ... folders at the same place). And builded it, then i changed jar file to exe.
    If i dont add my images folder at the same place with exe file it doesnt work.
    How can i hide these images in exe???
    is there anybody give advices??

    Here is code, with a lot of shortcuts, but showing how to properly load an image included in a JAR:
    package jGetResource;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class jGetResource {
      public jGetResource(){
        try{
          BufferedImage bi = ImageIO.read(this.getClass().getResource("image/myImage.jpg")); //this is the line you need--the rest is just shortcut code not meant as what you should do in your project.
          new MyJFrame(bi).setVisible(true);
        }catch(IOException e){
          System.out.println(e.toString()); //remember ALWAYS ALWAY ALWAYS report failure--otherwise how to do you know why it's not working?
      public static void main(String[] args) {
        new jGetResource();
      class MyJFrame extends JFrame{
        BufferedImage bi;
        MyJFrame(BufferedImage bi){
          this.bi = bi;
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          this.setSize(new Dimension(bi.getWidth(), bi.getHeight()));
          this.setResizable(false);
        public void paint(Graphics g){
          g.drawImage(bi,0,0,this);
    }Note: to include your image (image/myImage.jpg) in the JAR, drag and drop the folder containing the image into the package for your project.
    Also please note: this is a shortcut--Since bi is drawn directly onto the JFrame, paint has to be extended because it is the outer most container--no JPanel or other component to display is used. Also setSize is used instead of setPerferredSize as this is the outermost container and no layout manager is in effect. Also pack() is not used as this is the outer most container and no ordering of contents is needed. Also note super.paint(g) is not called as this is a one time use container--show it and close it.

  • J2me multipart file upload-  Help Needed

    package com.mpbx;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.io.*;
    public class PostFile extends MIDlet implements Runnable, CommandListener{
        private final String FILE = "/image.jpg";
        private final String URL = "http://localhost/post.php"; // change this to a valit page.
        private final String CrLf = "\r\n";
        private Form form = null;
        private Gauge gauge = null;
        private Command exitCommand;
        private Command uploadCommand;
        public PostFile(){
            form = new Form("Upload File");
            gauge = new Gauge("Progress:", true, 100, 0);
            form.append(gauge);
            exitCommand = new Command("Exit", Command.EXIT, 0);
            uploadCommand = new Command("Upload", Command.SCREEN, 0);
            form.addCommand(exitCommand);
            form.addCommand(uploadCommand);
            form.setCommandListener(this);
        public void startApp() {
            Display.getDisplay(this).setCurrent(form);
        public void pauseApp() {
        public void destroyApp(boolean unconditional) {
        private void progress(int total, int current){
            int percent = (int) (100 * ((float)current/(float)total));
            gauge.setValue(percent);
        public void run() {
            httpConn();
        private void httpConn(){
            HttpConnection conn = null;
            OutputStream os = null;
            InputStream is = null;
            try{
                System.out.println("url:" + URL);
                conn = (HttpConnection)Connector.open(URL);
                conn.setRequestMethod(HttpConnection.POST);
                String postData = "";
                InputStream imgIs = getClass().getResourceAsStream(FILE);
            byte []imgData = new byte[imgIs.available()];
               imgIs.read(imgData);
                String message1 = "";
                message1 += "-----------------------------4664151417711" + CrLf;
                message1 += "Content-Disposition: form-data; name=\"uploadedfile\"; filename=\"" + FILE + "\"" + CrLf;
                message1 += "Content-Type: image/jpeg" + CrLf;
                message1 += CrLf;
                // the image is sent between the messages ni the multipart message.
                String message2 = "";
                message2 += CrLf + "-----------------------------4664151417711--" + CrLf;              
                conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=---------------------------4664151417711");
                // might not need to specify the content-length when sending chunked data.
                // conn.setRequestProperty("Content-Length", String.valueOf((message1.length() + message2.length() + imgData.length)));
                System.out.println("open os");
                os = conn.openOutputStream();
                System.out.println(message1);
                os.write(message1.getBytes());
                // SEND THE IMAGE
                int index = 0;
                int size = 1024;
                do{
                    System.out.println("write:" + index);
                    if((index+size)>imgData.length){
                        size = imgData.length - index;
                    os.write(imgData, index, size);
                    index+=size;
                    progress(imgData.length, index); // update the progress bar.
                }while(index<imgData.length);
                System.out.println("written:" + index);           
                System.out.println(message2);
                os.write(message2.getBytes());
                os.flush();
                System.out.println("open is");
                is = conn.openInputStream();
                char buff = 512;
                int len;
                byte []data = new byte[buff];
                do{
                    System.out.println("READ");
                    len = is.read(data);
                    if(len > 0){
                        System.out.println(new String(data, 0, len));
                }while(len>0);
                System.out.println("DONE");
            }catch(Exception e){
                e.printStackTrace();
            }finally{
                System.out.println("Close connection");
                try{
                    os.close();
                }catch(Exception e){}
                try{
                    is.close();
                }catch(Exception e){}
                try{
                    conn.close();           
                }catch(Exception e){}
        public void commandAction(javax.microedition.lcdui.Command command, javax.microedition.lcdui.Displayable displayable) {
            if(command == exitCommand){
                this.notifyDestroyed();
            }else if(command == uploadCommand){
                new Thread(this).start();
    }Running this yields the error below...Can someone suggest me. whats the problem.
    url:http://localhost/post.php
    java.lang.NullPointerException
            at com.mpbx.PostFile.httpConn(PostFile.java:85)
            at com.mpbx.PostFile.run(PostFile.java:68)
    Close connection

    I also faced the same problem. To make this code work you will have to include the image.jpg in the jar. To do that, copy the image file in the src directory inside your project folder (if you are using netbeans) and then build the project.
    Remember, the web server should be running in background.

  • Problem Web Dynpro Java applications using JasperReports

    Hello all,
    We have followed the footsteps of these blogs but we can not make it work.
    Part I --> Part-I: Print Web Dynpro Java applications using JasperReports
    Part II --> Part-II: Print Web Dynpro Java applications using JasperReports
    Part III --> Part-III: Print Web Dynpro Java applications using JasperReports
    Details system: 7.02 SP3
    We believe that the problem is in the library, because it finds them.
    1) We created project as a DC external library with *.jars
    2) Public part DC external library.
    3) Add public part of DC Library into new project DC WebDynpro Java.
    4) Development Component -> Build is OK
    5) Development Component -> Deploy is OK
    6) Test app ERROR.
    When we run the application shows the error:
    The initial exception that caused the request to fail, was:
       java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at com.unisys.tmb.View01.onActiongenerarPDF(View01.java:161)
        at com.unisys.tmb.wdp.InternalView01.wdInvokeEventHandler(InternalView01.java:140)
        at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
        ... 28 more
    See full exception chain for details.
    Regards,
    Luis.

    Hello John,
    Thanks for the link. We have performed the steps in this blog:
    1) Create DC Project "External Library" with name js/jars:
    - Add *.jars in folder Libraries.[Screenshot Libraries|http://img846.imageshack.us/img846/8395/jsjars.jpg]
    - Add archives (*.jar) to public part with name ExternalLib. Which option to choose?
    a- Provides an API for developing/compiling other DCs (Option chosen)
    b- Can be packaged into other build results (eg SDAs)
    - Development Component -&gt; Build
    Step 1 is OK.
    2) Create "J2EE Server Component / Library" DC with name js/lib:
    - Add Used DC -> public part project ExternalLibrary -> "ExternalLib"
    - Specify both build time and run-time dependency here and strong.
    - Generated SDA file in <var>gen/default/deploy</var> How do we check that it contains <var>js.jar</var>?
    - folder gen/default/plublic/defLib/lib/java then you meet *.jars files again. is OK.
    - Development Component -> Deploy.
    - Go to Visual Administrator. We found the library js/lib, but has no associated *. jar. It is the problem.[Screenshot Visual Administrator|http://img542.imageshack.us/img542/5537/visualadminlib.jpg]
    3) Create "WebDynpro" DC with name pdf_jasper
    - Add used DC (defLib) to WebDynpro DC with option "Build time".
    - WebDynpro References -> Library references --> add <var>jslib
    - Deploy
    - Run error: java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
    Regards,
    Luis.

  • How to make apparent that the VM is starting...

    Hello,
    even on pretty recent Windows boxes, the Java VM may take a few seconds to come up, especially the fist time it is launched. If the user double-clicks on a desktop icon that launches a Java-based application, nothing seems to happen for a while. Is there a way to make apparent that something is going on? For instance, is it possible to temporarily change the mouse cursors' appearence until the VM is warm?
    TIA to all volunteers.

    java -splash:"exedata\icons\MainTripBackgrounds\AAAwelcome.jpg" -Xms10m -Xmx500m -jar Presenter.jar
    is well working

  • Build a applcation on JDeveloper and want to run on SunAplicationServer 8

    In the folder /web-inf/libs has all jars with the libs....
    But I packaged the war of the application with jdev and deployed at SunApplicationServer.... When I go to url of the web applcation this erros is showed...
    http://img103.imageshack.us/img103/4816/imagem5aa.jpg
    jsf-api.jar, all myfaces.jar, all adffaces.jar is in the lib folder, but I don't know what steps I must to follow to run on SunApplicationServer...
    Thanks.

    You can setup Windows to run natively.
    There is a Mac version, I looked but didn't download or anything and not sure about ebay and of course AVOID at any rate using a Bittorrent version. Web-based?
    Windows apps are different. Older Mac apps also won't run under Lion and later.
    You need to realize your post shows an unsupported out of date 10.5.7 and you are in a forum that has nothing to do with the notebook line of Macs.

  • File access in a Java project under XCode

    Hello again,
    I have had another issue: I'm trying to have one of my classes read information from an XML file, whose location is in the same folder as the classes and, indeed, the project (and the .xcodeproj file).
    So I give the file's name to the method, but it cannot seem to find the file where I put it; instead, it looks for it in (Project folder)/Build/Debug/.
    What should I do? I do not feel it wise to put it into Build/Debug as it is a file that should be deployed along with the rest of the application (when I learn how to make one, that is), but after a little searching around I'm a bit at a loss about that.
    Thanks in advance,

    This option is normally used for storing preference
    files. If you have a number of files then you can
    create a folder to hold them. If you have a look
    around at the files which are already there (for
    other applications) you'll get the idea.
    Well, preference files are fine but I don't view them as useful for data.
    This folder
    is strictly OS X only, but I'll explain there's a way
    around that later on.
    I failed to catch that explanation, but you might want to leave it at that. No high priority as far as I'm concerned. (Of course, it could be of interest to anyone who finds this discussion - why else are we using a forum, right?)
    You can create a bundle from a Java program using
    Macintosh HD/Developer/Applications/Java Tools/Jar
    Bunder. Again, this is OS X only.
    Again, good to know, but not usable now by this developer.
    If your program relies on a number files (for example
    jpg files for graphics and wav files for sounds) then
    these can be added to the jar file. Xcode will do
    this for you if you add the file to the project, then
    drag it onto the Build Java Resources build phase.
    This form of words will extract the file called
    stars.jpg from the jar file:
    URL f = getClass ().getResource ("stars.jpg");
    image = ImageIO.read (f);
    Interesting, but the software I'm using as a model of sorts (as far as general design goes from a user point of view) seems to have little in the jar file besides classes. I'd like sufficiently advanced users to be able to access the data files directly (I'll make them nice XML files) but not get into the .jar. Tell you what, I just stumbled on the XML reading class and it seems to be using File.getAbsolutePath(). I must try this.
    This works on all Java platforms and so is often
    used. There is a standard Unix/Terminal command
    called jar which gives you fine control over a jar
    file. Type man jar in Terminal for details and more
    info about jar files.
    Thanks.
    6) You think you never mentioned a sixth option?
    Well, you did - in that other topic you answered.
    You
    gave me the idea of fiddling with project
    settings.
    Be aflaid, be vely aflaid! I have tried to use
    $(PROJECT_DIR) instead of $(inherited) in "Build
    Products Path" and "Per-configuration Build
    Products
    Path", but so far to no avail: running throws a
    "LaunchRunner Error" = "The main class
    "Main_Class"
    could not be found."
    These are Xcode options and probably won't be of much
    value to you.
    Well, they are. But I suddenly realize it may work fine and well while in debug, but not so well once everything is compiled and set into a nice application. I'll try this.
    BTW. Did you know that a Java program can find out
    which platform it's running on? Just call String
    opSys = System.getProperty ("os.name");
    This enables you to use different solutions for each
    different platform.
    Actually, I knew about System.getProperty. I've been trying to use it to imitate the Application.Path property from Visual Basic (the language I use most at work), that returns the current location of the application. Does there exist something like that in Java? I've tried System.getProperty with "user.dir", "java.home" and "java.class.path", to no avail: the first gives me Build/Debug (or Build/Release, depending on the build configuration), the second returns the place where you can find Java, in the System/Library structure, and the third yields a looooong path list.
    (Still, might be onto something with that File.getAbsolutePath() thingie. I really have to try it.)
    Thanks again for the elaboration, helpful as usual and rightly clicked so.
    iMac Mac OS X (10.4.8)

  • Using a JAR file as a project file

    My application allows the user to create projects. Previously, a project file was simply an XML file. Now, a project file needs to also contain many images.
    I thought it would be a good idea to simply use a JAR file as my project file.
    Since I've really never really worked with JAR files and the java.util.Jar package directly, I have a few questions.
    1) Would it be better just to simply store the images as binary in the XML file? I just spent a good amount of time making the XML file very readable so I thought it would be better to keep the images separate while still having a single "project" file.
    2) Is there anything inherently wrong with the way I'm working with the JAR file in the code below?
    Simple XML file:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE project [
      <!ELEMENT project (img+)>
      <!ELEMENT img EMPTY>
      <!ATTLIST img src CDATA #REQUIRED>
    ]>
    <project>
         <img src="blah.jpg"/>
    </project>
    import java.io.*;
    import java.util.jar.JarFile;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    public class LoaderTest {
        private String imageName;
        public LoaderTest() {
            InputStream i = null;
            JarFile jf = null;
            try {
                jf = new JarFile("project.jar");
                i = jf.getInputStream(jf.getJarEntry("project.xml"));
                // Here's my simple XML parser to load the project and images
                SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
                parser.parse(new InputSource(i), new DefaultHandler() {
                    @Override
                    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
                        // Right now we only care about images
                        if (qName.equalsIgnoreCase("img")) {
                            imageName = attributes.getValue("src");
                // Load the image from the inputstream
                java.awt.image.BufferedImage img = javax.imageio.ImageIO.read(jf.getInputStream(jf.getJarEntry(imageName)));
                // Display the image in a JFrame
                javax.swing.JFrame f = new javax.swing.JFrame();
                f.setLayout(new java.awt.BorderLayout());
                f.setSize(800, 600);
                f.getContentPane().add(new javax.swing.JLabel(new javax.swing.ImageIcon(img)), java.awt.BorderLayout.CENTER);
                f.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
                f.setVisible(true);
            } catch (ParserConfigurationException ex) {
                ex.printStackTrace();
            } catch (SAXException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            } finally {
                // Do our best to close the input streams
                if (i != null) {
                    try {
                        i.close();
                    } catch (IOException ex) {}
                if (jf != null) {
                    try {
                        jf.close();
                    } catch (IOException ex) {}
        public static void main(String[] args) {
            new LoaderTest();
    }Thank you!

    1) I also think it's much better to keep your images separate from your XML, this prevents a lot of in case you just want to read XML data
    2) What's exactly going wrong here? For the project.xml, make sure it's not inside a directory within the JAR file, or else the variable i will be null. Otherwise it looks fine..

  • Application works from NB but not from jar

    Hi,
    I'am programming a game in JAVA and this going as planned. Everything works when I run it from NetBeans, but when I execute the jar file from the console, then I get hunderds of the same exception.
    I really don't know what it is, I see a NoSuchMethod exception in the MouseEvent of the method getLocationOnScreen(), but just as i said, the app works fine without errors from out NB.
    Does somebody knows what the problem is?
    thx Sven
    java -jar Hotel.jar
    Loading board images.
    Loading image: /Images/bg-patern-hotel.jpg
    Opening file /Images/bg-patern-hotel.jpg file exisits: true -- [/Users/svenvanzoelen/NetBeansProjects/Games/Hotel/dist/Images/bg-patern-hotel.jpg]
    Loading image: /Images/Main-board-big.jpg
    Opening file /Images/Main-board-big.jpg file exisits: true -- [/Users/svenvanzoelen/NetBeansProjects/Games/Hotel/dist/Images/Main-board-big.jpg]
    Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: java.awt.event.MouseEvent.getLocationOnScreen()Ljava/awt/Point;
         at Engine.GameAction.setMousePos(GameAction.java:137)
         at Engine.InputManager.mouseMoved(InputManager.java:277)
         at java.awt.Component.processMouseMotionEvent(Component.java:5647)
         at java.awt.Component.processEvent(Component.java:5371)
         at java.awt.Container.processEvent(Container.java:2010)
         at java.awt.Window.processEvent(Window.java:1184)
         at java.awt.Component.dispatchEventImpl(Component.java:4068)
         at java.awt.Container.dispatchEventImpl(Container.java:2068)
         at java.awt.Window.dispatchEventImpl(Window.java:1801)
         at java.awt.Component.dispatchEvent(Component.java:3903)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Same error goes 50 times more.Edited by: Svenmeister on Apr 16, 2010 7:22 AM
    Edited by: Svenmeister on Apr 16, 2010 7:22 AM

    Ok, I updated my Mac but still got the 1.5.0_22 crap so I changed the function from the mouseEvent to one that 1.5 supports.
    But now when I run the application from the console the Exception about the mouse function is gone, but I got another exception instead of it. And this one is I believe not JRE version relevant.
    The error is in the loading of the images, at the third PNG image to be precise. The images are now in total 10.8MB in size.
    So is this also a 1.6 thing? Would be awesome if someone can explain it.
    java -jar Hotel.jar Loading board images.
    Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
         at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
         at java.awt.image.Raster.createPackedRaster(Raster.java:458)
         at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
         at sun.awt.image.ImageRepresentation.createBufferedImage(ImageRepresentation.java:223)
         at sun.awt.image.ImageRepresentation.setPixels(ImageRepresentation.java:469)
         at apple.awt.OSXImageRepresentation.setPixels(OSXImageRepresentation.java:66)
         at sun.awt.image.ImageDecoder.setPixels(ImageDecoder.java:120)
         at sun.awt.image.PNGImageDecoder.sendPixels(PNGImageDecoder.java:498)
         at sun.awt.image.PNGImageDecoder.produceImage(PNGImageDecoder.java:419)
         at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246)
         at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
         at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
         at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
         at java.awt.image.Raster.createPackedRaster(Raster.java:458)
         at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
         at java.awt.image.BufferedImage.<init>(BufferedImage.java:345)
         at apple.awt.CGraphicsConfig.createCompatibleImage(CGraphicsConfig.java:174)
         at GUI.Board.toBufferedImage(Board.java:1472)
         at GUI.Board.loadImages(Board.java:1143)
         at Engine.HotelMain.switchState(HotelMain.java:86)
         at Engine.HotelMain.<init>(HotelMain.java:57)
         at Engine.HotelMain.main(HotelMain.java:194)Edited by: Svenmeister on Apr 16, 2010 11:01 AM

Maybe you are looking for

  • Auto logins on websites no longer working

    I recently (a couple days ago) got a pop-up on the lower part of my screen that said that firefox was going kind of slowly or something along those lines and said if I would like to fix this that I could click this button. Well I did that and it took

  • MBP and LG Le5300

    Hi, I am connecting my MBP up to a 32" LG LED (LE5300) tv using DVI - HDMI cable. When I do this I can see the screen the picture looks bad...it is better when I do DVI - VGA. I am not sure if there is a driver update for lg tv's that can fix this or

  • Archive Area Used % Testing

    Hello, - My Oracle Version 11Gr2 , RAC using ASM and OMF. - OS Name: Redhat Linux 5.5 Issue: To test the SNMP Trap settings on database control (Not Grid Control), I would like to raise the Archive Area Used % alert. This is our test environment but

  • Yellow pop up box when hovering over links missing in CC?

    The behavior when hovering over links in the Links Panel in CS6 was a yellow pop up box with the full path of the link displayed. I find that is not the behavior in CC and I am really missing that. Have I missed a setting somewhere to enable this in

  • MacBook Pro will not work without external powersource

    Hello all, I have (and love) my MBP. I've never had issue with it until tonight. My battery is at 100% charged, but when I unhook the Magsafe power source, the MPB shuts off instantly - and will not spool up until it is plugged back in. Any ideas?