Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: can not find icon in .exe made by WinRun4j : java.lang.NullPointerException

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default can not find icon in .exe made by WinRun4j : java.lang.NullPointerException

    Hi all,

    I have a problem with icons.
    Part of code :

    Code:
    	private JButton getJButton() {
    		if (jButton == null) {
    			jButton = new JButton();
    			jButton.setPreferredSize(new Dimension(16, 16));
    			jButton.setFont(new Font("Dialog", Font.BOLD, 8));
    			jButton.setIcon(new ImageIcon(getClass().getResource("/com/img/cls.jpg"))); //---> This part fails
    			jButton.setHorizontalAlignment(SwingConstants.CENTER);
    			jButton.setHorizontalTextPosition(SwingConstants.CENTER);
    			jButton.setText("");
    			jButton.setOpaque(true);	
    			jButton.setVisible(false);			
    			jButton.addMouseListener(new java.awt.event.MouseAdapter() {   
    				public void mouseExited(java.awt.event.MouseEvent e) {    
    					jButton.setVisible(false);
    				}
    				public void mouseEntered(java.awt.event.MouseEvent e) {
    					jButton.setVisible(true);					
    				}
    			});
     
    		}
    		return jButton;
    	}
    Error :
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(Unknown Source)
    at com.FormMain.addtoJTabbedPane(FormMain.java:169)
    at com.FormMain.treeSelectionHandler(FormMain.java:12 5)
    at com.FormMain.access$0(FormMain.java:102)
    at com.FormMain$1.valueChanged(FormMain.java:67)
    at javax.swing.JTree.fireValueChanged(Unknown Source)
    at javax.swing.JTree$TreeSelectionRedirector.valueCha nged(Unknown Source)
    at javax.swing.tree.DefaultTreeSelectionModel.fireVal ueChanged(Unknown Source)
    at javax.swing.tree.DefaultTreeSelectionModel.notifyP athChange(Unknown Source)
    at javax.swing.tree.DefaultTreeSelectionModel.setSele ctionPaths(UnknownSource)
    at javax.swing.tree.DefaultTreeSelectionModel.setSele ctionPath(Unknown Source)
    at javax.swing.JTree.setSelectionPath(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI.selectPathForEv ent(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.handleS election(Unknown Source)
    at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePr essed(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)


    Tool : Eclipse
    Source Folder : src
    Package : com.img

    When i run or debug this code from eclipse it works, no problem.
    When i make runnable jar with this code, jar works, no problem.
    When i make .exe with this code using WinRun4j with export type= Standart option(jars are out of .exe, in a folder), .exe works, no problem.
    But when i make .exe with this code using WinRun4j and export type= Fat Executable option(jars and all files in .exe)it fails, can not find icons and .jrxml files.

    Icons are in com.img package in src source folder, but getClass().getResource("/com/img/cls.jpg") returns null??

    Whats the wrong or what can i do to solve this, anybody help ?

    okxx


  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: can not find icon in .exe made by WinRun4j : java.lang.NullPointerException

    Hi all again,

    I ve solved problem with diffrent method. I think this problem about WinRun4j plugin.

    Anyway i found a porgram names Jar2Exe. It creates exe with no problem, no banner, makes a clear exe.

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: can not find icon in .exe made by WinRun4j : java.lang.NullPointerException

    Hello okxx,

    I was just about to look into this. Glad you have solved your issue with a new program.

    I will mark this thread as solved.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. exception in thread main java.lang.Nullpointerexception
    By westandeast in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 6th, 2011, 09:08 AM
  2. java.lang.nullPointerException
    By ridg18 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 25th, 2010, 03:52 PM
  3. problem in java.lang.NullPointerException
    By jianghuzai in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 28th, 2010, 10:24 AM
  4. java.lang.NullPointerException - Help
    By mds1256 in forum Exceptions
    Replies: 5
    Last Post: November 30th, 2009, 06:31 PM
  5. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM