Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java.com.crosudd.t

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/anaini1314/article/details/71157894

异常错误:Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java.com.crosudd.test

是在测试包:包名出现了java.com.crosudd.test      java开头,应该改为  com.crosudd.test   把Java去掉 就可以了写测试类了。个人解决办法,如有不同请耐心在网上自行搜索

展开阅读全文

Prohibited package name: java.awt 怎么解决

03-12

代码如下:rnpackage prj_trayicon;rnrnimport java.awt.*;rnimport javax.swing.*;rnimport com.borland.jbcl.layout.XYLayout;rnimport com.borland.jbcl.layout.*;rnimport java.awt.event.ActionEvent;rnimport java.awt.event.ActionListener;rnimport java.awt.event.WindowEvent;rnimport java.awt.event.WindowAdapter;rnrnpublic class FrmTrayIcon extends JFramernrn JPanel contentPane;rn XYLayout xYLayout1 = new XYLayout();rn JButton jButton1 = new JButton();rn TrayIcon ti;rn PopupMenu popupMenu1 = new PopupMenu();rn MenuItem menuItem1 = new MenuItem();rn MenuItem menuItem2 = new MenuItem();rnrn public FrmTrayIcon()rn rn tryrn rn setDefaultCloseOperation(HIDE_ON_CLOSE);rn jbInit();rn rn catch (Exception exception)rn rn exception.printStackTrace();rn rn rnrn private void jbInit() throws Exceptionrn rn contentPane = (JPanel)getContentPane();rn contentPane.setLayout(xYLayout1);rn setSize(new Dimension(400, 300));rn setTitle("TrayIcon");rn this.addWindowListener(new FrmTrayIcon_this_windowAdapter(this));rn jButton1.setText("Exit");rn jButton1.addActionListener(new FrmTrayIcon_jButton1_actionAdapter(this));rn contentPane.add(jButton1, new XYConstraints(68, 48, -1, -1));rn menuItem1.setLabel("Show");rn menuItem1.addActionListener(new FrmTrayIcon_menuItem1_actionAdapter(this));rn menuItem2.setLabel("Exit");rn menuItem2.addActionListener(new FrmTrayIcon_menuItem2_actionAdapter(this));rn popupMenu1.add(menuItem1);rn popupMenu1.add(menuItem2);rn Image image = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("TrayIcon.png"));rn ti = new TrayIcon(image, "TrayIcon", popupMenu1);rn rnrn public void jButton1_actionPerformed(ActionEvent e)rn rn System.exit(0);rn rnrn public void this_windowClosing(WindowEvent e)rn rn if (SystemTray.isSupported())rn rn setVisible(false);rn MiniToTray();rn rn elsern rn System.exit(0);rn rn rnrn public void MiniToTray()rn rn SystemTray tray = SystemTray.getSystemTray();rn tryrn rn tray.add(ti);rn rn catch (AWTException e)rn rn System.err.println(e);rn rn rnrn public void menuItem1_actionPerformed(ActionEvent e)rn rn SystemTray.getSystemTray().remove(ti);rn setVisible(true);rn rn rn public void menuItem2_actionPerformed(ActionEvent e)rn rn SystemTray.getSystemTray().remove(ti);rn System.exit(0);rn rnrnrnclass FrmTrayIcon_menuItem1_actionAdapter implements ActionListenerrnrn private FrmTrayIcon adaptee;rn FrmTrayIcon_menuItem1_actionAdapter(FrmTrayIcon adaptee)rn rn this.adaptee = adaptee;rn rnrn public void actionPerformed(ActionEvent e)rn rn adaptee.menuItem1_actionPerformed(e);rn rnrnrnclass FrmTrayIcon_menuItem2_actionAdapter implements ActionListenerrnrn private FrmTrayIcon adaptee;rn FrmTrayIcon_menuItem2_actionAdapter(FrmTrayIcon adaptee)rn rn this.adaptee = adaptee;rn rnrn public void actionPerformed(ActionEvent e)rn rn adaptee.menuItem2_actionPerformed(e);rn rnrnrnclass FrmTrayIcon_this_windowAdapter extends WindowAdapterrnrn private FrmTrayIcon adaptee;rn FrmTrayIcon_this_windowAdapter(FrmTrayIcon adaptee)rn rn this.adaptee = adaptee;rn rnrn public void windowClosing(WindowEvent e)rn rn adaptee.this_windowClosing(e);rn rnrnrnclass FrmTrayIcon_jButton1_actionAdapter implements ActionListenerrnrn private FrmTrayIcon adaptee;rn FrmTrayIcon_jButton1_actionAdapter(FrmTrayIcon adaptee)rn rn this.adaptee = adaptee;rn rnrn public void actionPerformed(ActionEvent e)rn rn adaptee.jButton1_actionPerformed(e);rn rn 论坛

没有更多推荐了,返回首页