我在eclipse 里面写得程序运行正常。但是当我打包jar文件后。环境变量都设置好了。最后就是运行不成功public static byte[] decrypt(byte[] inData,byte[] keyData){
if(inData==null) throw new IllegalArgumentException();
try{
System.out.print("-----------1="+keyData.length);
SecretKey key=new SecretKeySpec(keyData,"RC4");
System.out.print("-----------2");
Cipher cipher=Cipher.getInstance("RC4");
System.out.print("-----------3");
cipher.init(Cipher.DECRYPT_MODE, key);
System.out.print("-----------4");
return cipher.doFinal(inData);
}catch(Exception e){
System.out.println(e.getMessage());
return null;
}
}
在elcipse中是正确的。
但是打包后运行结果:
-----------1=16-----------2Cannot find any provider supporting RC4
Exception in thread "main" java.lang.NullPointerException
at net.ideaBank.NMS.UserNameRuleItem.setBytes(NMSData.java:491)
at net.ideaBank.NMS.NMSServer.ReadNpsLicFile(NMSServer.java:104)
at net.ideaBank.NMS.NMSServer.start(NMSServer.java:52)
at net.ideaBank.NMS.Server.start(Server.java:31)
at TestNMSserver.main(TestNMSserver.java:51)
if(inData==null) throw new IllegalArgumentException();
try{
System.out.print("-----------1="+keyData.length);
SecretKey key=new SecretKeySpec(keyData,"RC4");
System.out.print("-----------2");
Cipher cipher=Cipher.getInstance("RC4");
System.out.print("-----------3");
cipher.init(Cipher.DECRYPT_MODE, key);
System.out.print("-----------4");
return cipher.doFinal(inData);
}catch(Exception e){
System.out.println(e.getMessage());
return null;
}
}
在elcipse中是正确的。
但是打包后运行结果:
-----------1=16-----------2Cannot find any provider supporting RC4
Exception in thread "main" java.lang.NullPointerException
at net.ideaBank.NMS.UserNameRuleItem.setBytes(NMSData.java:491)
at net.ideaBank.NMS.NMSServer.ReadNpsLicFile(NMSServer.java:104)
at net.ideaBank.NMS.NMSServer.start(NMSServer.java:52)
at net.ideaBank.NMS.Server.start(Server.java:31)
at TestNMSserver.main(TestNMSserver.java:51)
這部出錯啊,說是不支持
getInstance里面的對象是空才報空指針的
你把引號去掉呀+了引號是string型的不+才是String型的呀
如果没用过加密算法的请别乱回答。多谢合作。
你沒聽懂我意思
我叫你getinstance里面放個對象不要直接用""這樣子的
if(inData==null) throw new IllegalArgumentException();
try{
for(int i=0;i<keyData.length;i++){
System.out.print(keyData[i]+",");
}
SecretKey key=new SecretKeySpec(keyData,"RC4");
System.out.print("-----------2");
Cipher cipher=Cipher.getInstance("RC4");
System.out.print("-----------3");
cipher.init(Cipher.DECRYPT_MODE, key);
System.out.print("-----------4");
return cipher.doFinal(inData);
}catch(Exception e){
System.out.println("ERR="+e.getMessage());
return null;
}
}
-----------------------------------------------------------------------
D:\NMS>java TestNMSserver
-91,56,63,15,65,-82,-74,74,-54,-90,-79,59,-78,-44,-78,-15,-----------2ERR=Cannot
find any provider supporting RC4
Exception in thread "main" java.lang.NullPointerException
at net.ideaBank.NMS.UserNameRuleItem.setBytes(NMSData.java:491)
at net.ideaBank.NMS.NMSServer.ReadNpsLicFile(NMSServer.java:104)
at net.ideaBank.NMS.NMSServer.start(NMSServer.java:52)
at net.ideaBank.NMS.Server.start(Server.java:31)
at TestNMSserver.main(TestNMSserver.java:51)
都不對額
在推測下,你打包的時候相關的jar一道打了么?MAINFEST里面是不是也指定了?