cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bnorton916
Level 3

Bringing in files

I have a custom code panel that needs to display different text depending upon the platform the installer is run on.
I pull this text from a file.

Everything works fine if I hard code the path and the file exist.
But when it is installed, the customcodepanel doesn't know where to find the file as nothing has been installed on the machine yet.

I tried including the files in the jar file, but I don't know how to access the jar file during the install.

How have others got around this problem?

Remember my java is not the strongest so type slow. 😉

Bill
Labels (1)
0 Kudos
(7) Replies
bnorton916
Level 3

Looks like I might be able to use

customCodePanelProxy.getResource

Bill
0 Kudos
bnorton916
Level 3

That doesn't seem to be working. Keeping getting NullPointerException. so if anyone has any ideas, let me know.

Bill
0 Kudos
pv7721
Level 20

Would you mind posting the entire exception you get?
0 Kudos
bnorton916
Level 3

Away from work on the weekend:

public class DisplayImage extends CustomCodePanel implements ActionListener,ItemListener {
.
.
.
.
public boolean setupUI( CustomCodePanelProxy ccpp ) {
if(!inited) {
//
// set the flag to true.
//
inited = true;
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
this.setLayout( gridbag);

TextArea txtAreaLic = new TextArea();
FileReader fr = null;

try {
URL myurl = ccpp.getResource("EULA.win");
}
catch (MalformedURLException e) {
System.err.println(e);
}
licFile = new File(myurl.getFile());


The licFile is the line where the execption occurs.
I have also tried using CustomCodePanelProxy.getResource("EULA.win")
EULA.win is in the top level of the jar file.

Now for the exception:

System's temporary directory = C:\Documents and Settings\Administrator\Local Settings\Temp

Loading externalized properties
Error running install panel: License Agreement
java.lang.NullPointerException
java.lang.NullPointerException
at com.zerog.ia.customcode.installpanels.DisplayImage.setupUI(DisplayImage.java:156)
at com.zerog.ia.installer.AAMgr.a(DashoA10*..)
at com.zerog.ia.installer.AAMgr.a(DashoA10*..)
at com.zerog.ia.installer.AAMgrBase.e(DashoA10*..)
at com.zerog.ia.installer.AAMgrBase.m(DashoA10*..)
at com.zerog.ia.installer.AAMgr.a(DashoA10*..)
at com.zerog.ia.installer.AAMgrBase.e(DashoA10*..)
at com.zerog.ia.installer.AAMgrBase.m(DashoA10*..)
at com.zerog.ia.installer.AAMgr.g(DashoA10*..)
at com.zerog.ia.installer.AAMgr.actionPerformed(DashoA10*..)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown 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.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Line 156 is the licFile line.
0 Kudos
pv7721
Level 20

Well the problem seem to be with the access to the EULA file right? Shouldn't that be a full path to the file?
0 Kudos
purcellk24
Level 7

A word about the getResource(String archivePath) method. Make sure the resource is in the installer, not the same jar file as the custom panel. A suggestion may be is to add it to the DO_NOT_INSTALL folder in the Install step. Then use that path to the file in your source code.

What you can also do is to package up the lic file in the same jar file as your custom panel, but then you have to use the getClass().getResource(String) or getClass().getResourceAsStream(String) method and maybe have to add a leading / to the string.
0 Kudos
bnorton916
Level 3

I am using this file in the pre-install step.

I can't put a full path because the files are not installed on the system.

About the DO_NOT_INSTALL idea, in IA do I have access to these files in the pre-install phase? If so how? getVariable()?

"What you can also do is to package up the lic file in the same jar file as your custom panel, but then you have to use the getClass().getResource(String) or getClass().getResourceAsStream(String) method and maybe have to add a leading / to the string."

Will try this out also.
0 Kudos