hello there, i would like to ask is there a way to throw away all exception as i have errors of unreported exception everywhere and how to i get a key out from the object after casting it into an object.
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.
hello there, i would like to ask is there a way to throw away all exception as i have errors of unreported exception everywhere and how to i get a key out from the object after casting it into an object.
You could wrap a block of code in a try / catch block and in the catch section, catch Exception and ignore it. I strongly urge you *NOT* to do this unless you also enjoy driving a motorcycle with a blindfold on and have your organ donor card with you.
Perhaps we can better help you if you post your code and your exception messages.as i have errors of unreported exception everywhere and how to i get a key out from the object after casting it into an object.
copeg (January 26th, 2013)
sorry for the double posting as when i came back to the old post it disappeared from where i put it and well, i couldnt find it. do i wrap the whole thing in a try /catch or catch them one by one?
myClient.java:34: error: unreported exception CertificateException; must be caug ht or declared to be thrown CertificateFactory certfac = CertificateFactory.getInstance("X.509"); ^ myClient.java:36: error: unreported exception FileNotFoundException; must be cau ght or declared to be thrown FileInputStream CA = new FileInputStream ("ca.cer"); ^ myClient.java:37: error: unreported exception CertificateException; must be caug ht or declared to be thrown Certificate CACert = certfac.generateCertificate(CA); ^ myClient.java:38: error: unreported exception IOException; must be caught or dec lared to be thrown CA.close(); ^ myClient.java:44: error: unreported exception FileNotFoundException; must be cau ght or declared to be thrown FileInputStream server = new FileInputStream (serveruser +".cer"); ^ myClient.java:45: error: unreported exception CertificateException; must be caug ht or declared to be thrown Certificate serverCert = certfac.generateCertificate(server); ^ myClient.java:51: error: unreported exception IOException; must be caught or dec lared to be thrown while ((nRead = server.read(data, 0, data.length)) != -1) { ^ myClient.java:54: error: unreported exception IOException; must be caught or dec lared to be thrown buffer.flush(); ^ myClient.java:55: error: unreported exception IOException; must be caught or dec lared to be thrown server.close(); ^ myClient.java:63: error: unreported exception FileNotFoundException; must be cau ght or declared to be thrown FileInputStream fis = new FileInputStream(file); ^ myClient.java:64: error: unreported exception IOException; must be caught or dec lared to be thrown fis.read(sigBytes); ^ myClient.java:65: error: unreported exception IOException; must be caught or dec lared to be thrown fis.close(); ^ myClient.java:66: error: unreported exception Exception; must be caught or decla red to be thrown boolean veri=verifySig(data,CACertPub,sigBytes); ^ myClient.java:76: error: unreported exception FileNotFoundException; must be cau ght or declared to be thrown RandomAccessFile raf = new RandomAccessFile(clie ntuser+".pk8", "r"); ^ myClient.java:77: error: unreported exception IOException; must be caught or dec lared to be thrown byte[] buf = new byte[(int)raf.length()]; ^ myClient.java:78: error: unreported exception IOException; must be caught or dec lared to be thrown raf.readFully(buf); ^ myClient.java:79: error: unreported exception IOException; must be caught or dec lared to be thrown raf.close(); ^ myClient.java:81: error: unreported exception NoSuchAlgorithmException; must be caught or declared to be thrown KeyFactory kf = KeyFactory.getInstance("RSA"); ^ myClient.java:82: error: unreported exception InvalidKeySpecException; must be c aught or declared to be thrown PrivateKey ClientPriv = kf.generatePrivate(kspec); ^ myClient.java:92: error: unreported exception IOException; must be caught or dec lared to be thrown out = new ObjectOutputStream(bos); ^ myClient.java:93: error: unreported exception IOException; must be caught or dec lared to be thrown out.writeObject(Aesobj); ^ myClient.java:95: error: unreported exception IOException; must be caught or dec lared to be thrown out.close(); ^ myClient.java:96: error: unreported exception IOException; must be caught or dec lared to be thrown bos.close(); ^ myClient.java:99: error: unreported exception IOException; must be caught or dec lared to be thrown streamOut.writeUTF(asHex(aessend)); ^ myClient.java:100: error: unreported exception Exception; must be caught or decl ared to be thrown byte[] signatureaes=signData(aessend,ClientPriv); ^ myClient.java:101: error: unreported exception IOException; must be caught or de clared to be thrown streamOut.writeUTF(AESEncrypt(AESKey,asHex(signatureaes))); ^ myClient.java:113: error: unreported exception Exception; must be caught or decl ared to be thrown byte[] signature=signData(encryptedline.getBytes(),ClientPriv); ^ myClient.java:162: error: unreported exception NoSuchAlgorithmException; must be caught or declared to be thrown KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); ^ myClient.java:178: error: unreported exception NoSuchAlgorithmException; must be caught or declared to be thrown Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); ^ myClient.java:179: error: unreported exception InvalidKeyException; must be caug ht or declared to be thrown cipher.init(Cipher.ENCRYPT_MODE,ClientPriv); ^ myClient.java:180: error: unreported exception IllegalBlockSizeException; must b e caught or declared to be thrown byte[] firstcipher=cipher.doFinal(Aestxt); ^ myClient.java:181: error: unreported exception InvalidKeyException; must be caug ht or declared to be thrown cipher.init(Cipher.ENCRYPT_MODE,ServerPub); ^ myClient.java:182: error: unreported exception IllegalBlockSizeException; must b e caught or declared to be thrown byte[] seccipher= cipher.doFinal(firstcipher); ^ myClient.java:190: error: unreported exception NoSuchAlgorithmException; must be caught or declared to be thrown Cipher c = Cipher.getInstance("AES"); ^ myClient.java:192: error: unreported exception InvalidKeyException; must be caug ht or declared to be thrown c.init(Cipher.ENCRYPT_MODE, AESKey); ^ myClient.java:194: error: unreported exception IllegalBlockSizeException; must b e caught or declared to be thrown byte[] ciphertxt=c.doFinal(Ptxt); ^ Note: myClient.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 36 errors
You need to evaluate each exception and see what the code should do when or if it is thrown.
Those you can recover from and retry the logic say when the user enters bad data and you want to try it again
and those that mean the program can't continue where you'll issue an error message and exit the program.
If you don't understand my answer, don't ignore it, ask a question.