Jump to content

Recommended Posts

I'm writing a Java app in BlueJ which will be platform independent. In my working directory I have an Images folder which contain 5 png images. When I'm working with relative paths do I use \\ or /? This is what I have:

 

        this.new_project = new JMenuItem("New Project", new ImageIcon ("Images/document-new.png"));
        this.new_project.addActionListener (this);
        
        this.open_project = new JMenuItem("Open Project", new ImageIcon ("Images/document-open.png"));
        this.open_project.addActionListener (this);
        
        this.save_project = new JMenuItem("Save Project", new ImageIcon ("Images/document-save.png"));
        this.save_project.addActionListener (this);
        
        this.save_project_as = new JMenuItem("Save Project As", new ImageIcon ("Images/document-save-as.png"));
        this.save_project_as.addActionListener (this);
        
        this.quit = new JMenuItem("Quit", new ImageIcon ("Images/system-log-out.png"));
        this.quit.addActionListener (this);

 

If I have BlueJ run the main(String[]) method on Windows, it works. On linux it works when I use the jar file, but on Windows it doesn't. If I swap the / for \\ it does not work on either OS.

Link to comment
https://forums.phpfreaks.com/topic/187629-loading-image-stored-in-jar-not-working/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.