ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

java.lang.ArrayStoreException in java program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: java.lang.ArrayStoreException in java program

    Originally posted by davisty View Post
    I just have to say I dont know what the problem is. I can say though, that there are NOT enough java debugging tools on the i5 to be able to resolve the issue. You cannot see the value of string variables or anything. I am basically shooting in the dark.
    I haven't searched for this here at CODE400, but there is a variety of java debugging tools you can use that may give what you asked for. Consider starting a new thread that can collect examples in a single location. You could start with a description of how your java is (1) developed and (2) called. I suspect that someone is familiar with an appropriate debug facility for your situation, and others might add alternatives for other methods.

    Having such a thread here would likely be useful to many developers. Java isn't my area, so I've only looked into details I've needed for particular problems and don't have enough solid background. However, I have run across a couple debugging features that could be helpful to you depending on how you do your development and testing.
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #17
      Re: java.lang.ArrayStoreException in java program

      I was talking about an i5 debugger. The green screen debugger is not sufficient to do java debugging. All the code was developed on the i5 to prevent any unsupported class errors.

      But when trying to debug JNI programs using the i5 debugger, it wouldnt tell my useful information about classes, or variables, woefully under powered. IBM needs to develop one if they want i5 developers to use java and JNI

      Comment


      • #18
        Re: java.lang.ArrayStoreException in java program

        I wasnt instantiating the dedrypt method correctly.

        Code to do decryption:

        Code:
        public class getDecrypt {
        
        	private String input;
        	
        	public getDecrypt() {
        	}
        	
        	public String thisDecrypt (String input) throws Exception {
        	 pashaAES AES = new pashaAES();
        	 String yString = AES.decrypt(input);
        	 return yString;
        	}
        	
        }
        Calls this

        Code:
        import java.net.URLDecoder;
        import java.net.URLEncoder;
        import java.security.MessageDigest;
        import java.util.Arrays;
        
        import javax.crypto.KeyGenerator;
        import javax.crypto.SecretKey;
        import javax.crypto.spec.SecretKeySpec;
        import javax.crypto.spec.IvParameterSpec;
         
        import javax.crypto.Cipher;
        import javax.crypto.spec.IvParameterSpec;
        import javax.crypto.spec.SecretKeySpec;
        
        import java.util.Arrays;
        import java.io.*; 
        
        import org.apache.commons.codec.binary.Base64;
        
         
        public class pashaAES  {
        
        	
        	private static String IV = "My super secret code";
        	private static String Key = "My super duper secret code";
        	
        	
         private String input;
         
         public pashaAES () {
        	 
         }
        
        public pashaAES(String input) throws Exception {
        	this.input = input;
        	
        	
         }
         
           
         public String  decrypt(String input) throws Exception{
        	 
        	
        	String input2 = input.trim(); 
        
        	String decodedUrl = URLDecoder.decode(input2, "UTF-8");
        	
        	byte[] decodedIV = Base64.decodeBase64(IV);
        	byte[] decodedKey = Base64.decodeBase64(Key);  
        	byte[] decodedinput =  Base64.decodeBase64(decodedUrl);
        	
        	
            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "IBMJCE"); // The below code depends on encryption used
            SecretKeySpec key = new SecretKeySpec(decodedKey, "AES");            // This is for AES
            cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(decodedIV));
            return new String(cipher.doFinal(decodedinput));
             
          }
        
        }
        Last edited by davisty; July 9, 2014, 06:36 AM. Reason: add notes

        Comment


        • #19
          Re: java.lang.ArrayStoreException in java program

          Originally posted by davisty View Post
          I was talking about an i5 debugger. The green screen debugger is not sufficient to do java debugging. All the code was developed on the i5 to prevent any unsupported class errors.
          And I was also referring to various i5 debuggers. There are multiple "i5 debuggers". (I've used at least three different "i5 debuggers" from IBM.)

          When you say "developed on the i5", you surely don't mean via green-screen, do you?
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment

          Working...
          X