I am trying to run this code. It is giving me the error:
Exception in thread "main" java.lang.NoClassDefFoundError: aim_basic
package aim;
import javax.net.ssl.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.security.*;
public class aim_basic {
public static void main(String[] Args){
try{
StringBuffer sb = new StringBuffer();
sb.append("x_login=yourloginid&"); // replace with
your own
sb.append("x_password=kjshdkjshfkdshhd&"); // replace with
your own
sb.append("x_version=3.1&");
sb.append("x_test_request=TRUE&"); // for testing
sb.append("x_method=CC&");
sb.append("x_type=AUTH_ONLY&");
sb.append("x_amount=1.00&");
sb.append("x_delim_data=TRUE&");
sb.append("x_delim_char=|&");
sb.append("x_relay_response=FALSE&");
sb.append("x_description=Java Transaction&");
// open secure connection
URL url = new URL("https://mygatewaysite/trfile.dll");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type","application/x-www-
form-urlencoded");
// POST the data in the string buffer
DataOutputStream out = new DataOutputStream(
connection.getOutputStream() );
out.write(sb.toString().getBytes());
out.flush();
out.close();
// process and read the gateway response
BufferedReader in = new BufferedReader(new InputStreamReader
(connection.getInputStream()));
String line;
line = in.readLine();
in.close(); // no more data
System.err.println(line);
Vector ccrep = split("|", line);
System.out.print("Response Code: ");
System.out.println(ccrep.elementAt(0));
System.out.print("Human Readable Response Code: ");
System.out.println(ccrep.elementAt(3));
System.out.print("Approval Code: ");
System.out.println(ccrep.elementAt(4));
System.out.print("Trans ID: ");
System.out.println(ccrep.elementAt(6));
System.out.print("MD5 Hash Server: ");
System.out.println(ccrep.elementAt(37));
}catch(Exception e){
e.printStackTrace();
}
}
// utility functions
public static Vector split(String pattern, String in){
int s1=0, s2=-1;
Vector out = new Vector(30);
while(true){
s2 = in.indexOf(pattern, s1);
if(s2 != -1){
out.addElement(in.substring(s1, s2));
}else{
//the end part of the string (string not
pattern terminated)
String _ = in.substring(s1);
if(_ != null && !_.equals("")){
out.addElement(_);
}
break;
}
s1 = s2;
s1 += pattern.length();
}
return out;
}
public static String toHexString ( byte[] b ){
StringBuffer sb = new StringBuffer( b.length * 2 );
for ( int i=0 ; i<b.length ; i++ )
{
// look up high nibble char
sb.append( hexChar [ ( b[ i] & 0xf0 ) >>> 4 ] ) ;
// look up low nibble char
sb.append( hexChar [ b[ i] & 0x0f ] ) ;
}
return sb.toString() ;
}
// table to convert a nibble to a hex character
static char[] hexChar = {
'0' , '1' , '2' , '3' ,
'4' , '5' , '6' , '7' ,
'8' , '9' , 'A' , 'B' ,
'C' , 'D' , 'E' , 'F' }
;
}