JAR files ...
Hi,
I am trying to use a number of classes stored as a package within a .jar file by importing them at the start of some applet code (see below) ...
However when I put my applet in to its own .jar ( which also includes the jar described above and a DLL that is required ) the applet throws up an error. The error comes when I try to create a new object from the classes within the first jar file... Error shown below.
Exception in thread "AWT-EventQueue-1" java.lang.ExceptionInInitializerError
at regView.readKey(regView.java:75)
at regView.actionPerformed(regView.java:92)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
95)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.security.AccessControlException: access denied (java.lang.Runtim
ePermission loadLibrary.jRegistryKey)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:323)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkLink(SecurityManager.java:818)
at java.lang.Runtime.loadLibrary0(Runtime.java:817)
at java.lang.System.loadLibrary(System.java:1030)
at ca.beq.util.win32.registry.RegistryKey.<clinit>(RegistryKey.java:88)
... 26 more
My code is as follows
// TestApplet.java
import java.io.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import ca.beq.util.win32.registry.*;// This is the jar file that is also included in the main jar
publicclass regViewextends JAppletimplements ActionListener
{
private JPanel pane =null;
private JScrollPane scrolling =null;
private JTextPane fileBox =null;
private JTextField keyname =null;
private JTextField valname =null;
private JButton butLoad =null;
privatefinal String LOAD ="load";
publicvoid init()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
privatevoid jbInit()throws Exception
{
pane =new JPanel();
pane.setBounds(new Rectangle(0, 0, 500, 325));
pane.setLayout(null);
pane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
pane.setBackground(new Color(0, 0, 0));
fileBox =new JTextPane();
fileBox.setText("");
fileBox.setEditable(false);
scrolling =new JScrollPane(fileBox);
scrolling.setBounds(new Rectangle(16, 110, 295, 200));
keyname =new JTextField();
keyname.setText("");
keyname.setBounds(new Rectangle(16, 23, 206, 29));
valname =new JTextField();
valname.setText("");
valname.setBounds(new Rectangle(16, 65, 206, 29));
butLoad =new JButton();
butLoad.setBounds(new Rectangle(231, 23, 80, 30));
butLoad.setText("Show");
butLoad.setActionCommand(LOAD);
butLoad.addActionListener(this);
pane.add(scrolling);
pane.add(keyname);
pane.add(valname);
pane.add(butLoad);
setContentPane(pane);
}
private String readKey(String key, String val)
{
System.out.println(key);
RegistryKey r =new RegistryKey(RootKey.HKEY_CURRENT_USER, key);
if(r.hasValue(val))
{
RegistryValue v = r.getValue(val);
return v.toString();
}
return"Key not found !";
}
publicvoid actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals(LOAD))
{
fileBox.setText(readKey(keyname.getText(), valname.getText()));
}
}
}
Any ideas why this might be ?
Any help is much appreciated.
Message was edited by:
chris_j_pook

