JRE Error

Dear all

I use jre1.5.0_05.i want to use java command for my program in command promt(windows xp sp2) mode.

but after running this command,this error is appeared:

Exception in thread "main" java.lang.NoClassDefFoundError.

this is my code:

package mb.gsm;

import java.util.*;

import java.text.*;

import org.w3c.dom.*;

import javax.xml.parsers.*;

import java.io.*;

public class Gsm

{

// converts the strings to numbers and adds them up the result is the sum as a string

public static String addDigits(String source, String param)

{

if(param.length() == 0)

throw(new IllegalArgumentException("Invalid parameter passed to addDigits") );

String shelp = new String();

int i;

for(i = 0;i < source.length();++i)

{

shelp += "3";

shelp += source.charAt(i);

}

source = shelp;

for(i = 0;i < source.length() / 2;i += 2)

{

if(source.charAt(i) != '3' || source.charAt(i) < '0' || source.charAt(i) >'9')

throw(new IllegalArgumentException("addDigits: Self contains bytes other than characters 0-9.") );

}

if (source.length() / 2 < param.length() )

throw(new IllegalArgumentException("addDigits: Self is to large for target.") );

String sP = param;

for(i = 0;i < source.length() / 2 - param.length();++i)

sP="0"+sP;

int carry = 0;

byte[] sumStr = source.getBytes();

// convert each digit to a number and add

for (i = sP.length() - 1;i >= 0 ;--i)

{

int op1 = sumStr[i * 2 + 1] - '0';

int op2 = sP.charAt(i) - '0';

int sum = op1 + op2 + carry;

carry = 0;

if (sum > 9)

{

carry = 1;

}

int digit = sum % 10 + '0';

sumStr[i * 2 + 1] = (byte)digit;

}

if(carry != 0)

throw(new IllegalArgumentException("addDigits: Overflow error.") );

String res = new String(sumStr);

return res;

}

// flips bytes in a string, returns the modified string

public static String flipBytePairs(String stringToModify)

{

if (stringToModify.length() % 4 != 0)

throw(new IllegalArgumentException("Invalid string passed to flipBytePairs") );

String modified = new String();

int i;

for (i = 0;i < stringToModify.length();i += 4)

{

modified += stringToModify.charAt(i + 2);

modified += stringToModify.charAt(i + 3);

modified += stringToModify.charAt(i + 0);

modified += stringToModify.charAt(i + 1);

}

return modified;

}

public static String fillLeft(String stringToFill, String hexStringToAppend, int length)

{

try

{

// throw exception if string is not valid

getByteFrom2HexDigits(hexStringToAppend);

}

catch(NumberFormatException ex)

{

throw(ex);

}

int n = 2 * length - stringToFill.length();

if (n < 0 || n % 2 != 0)

{

throw(new IllegalArgumentException("Invalid length passed to fillLeft") );

}

String filled = stringToFill;

int i;

for (i = 0;i < n;i += 2)

filled += hexStringToAppend;

return filled;

}

public static String fillRight(String stringToFill, String hexStringToInsert, int length)

{

try

{

// throw exception if string is not valid

getByteFrom2HexDigits(hexStringToInsert);

}

catch(NumberFormatException ex)

{

throw(ex);

}

int n = 2 * length - stringToFill.length();

if (n < 0 || n % 2 != 0)

{

throw(new IllegalArgumentException("Invalid length passed to fillLeft") );

}

String filled = stringToFill;

int i;

for (i = 0;i < n;i += 2)

filled = hexStringToInsert + filled;

return filled;

}

public static String flipNibbles(String source)

{

if(source.length() % 2 != 0)

throw (new IllegalArgumentException("Invalid hex string passed to flipNibbles") );

String target = new String();

int i;

for (i = 0;i < source.length();i += 2)

{

target += source.charAt(i + 1);

target += source.charAt(i + 0);

}

return target;

}

public static String addBcd(String source, String param)

{

int i;

for(i = 0;i < source.length();++i)

{

if(source.charAt(i) < '0' || source.charAt(i) > '9')

throw (new IllegalArgumentException("Invalid hex string passed to addBcd") );

}

if (param.length() == 0)

{

throw (new IllegalArgumentException("Invalid hex string passed to addBcd") );

}

for(i = 0;i < param.length();++i)

{

if(param.charAt(i) < '0' || param.charAt(i) >'9')

throw (new IllegalArgumentException("Invalid hex string passed to addBcd") );

}

String sP = param;

for(i = 0;i < source.length() - param.length();++i)

{

sP = "0" + sP;

}

String sumStr = new String();

int carry = 0;

// convert each digit to a number and add

for (i = sP.length() - 1;i >= 0 ;--i)

{

int op1 = source.charAt(i) - '0';

int op2 = sP.charAt(i) - '0';

int sum = op1 + op2 + carry;

carry = 0;

if (sum > 9)

{

carry = 1;

}

int digit = sum % 10 + '0';

sumStr = (char)digit + sumStr;

}

if(carry != 0)

throw (new IllegalArgumentException("addBcd: Overflow") );

return sumStr;

}

public static String luhnBcdCheckDigit(String source)

{

int i;

for(i = 0;i < source.length() - 1;++i)

{

if(source.charAt(i) <'0' || source.charAt(i) > '9')

throw (new IllegalArgumentException("luhnBcdCheckDigit: At least one nibble of self doesn't contain bcd.") );

}

int sum=0;

int nibble=0;

byte[] tmp = source.getBytes();

for(i = 0;i < source.length() - 1;++i)

{

if(i % 2 != 0)

{

sum += tmp - '0';

}

else

{

if ( (tmp - '0') * 2 > 9)

{

sum += ( (tmp - '0') * 2) % 10 + 1;

}

else

{

sum += (tmp - '0') * 2;

}

}

}

sum = ( ( (sum / 10) + 1) * 10 - sum) % 10;

tmp[source.length() - 1] = (byte)(sum + '0');

source = new String(tmp);

return source;

}

// helper method to convert a string of length 2 containing 2 hex digits to a byte

static byte getByteFrom2HexDigits(String hexStr)

{

if (hexStr.length() != 2)

throw(new NumberFormatException(new String("invalid string = " + hexStr) ) );

Integer num;

String toDecode = "0x" + hexStr;

try

{

num = Integer.decode(toDecode);

}

catch(NumberFormatException ex)

{

throw(ex);

}

return num.byteValue();

}

// helper function to convert a double to a hex string with a specified length

static String toHexString(double num, int lengthOfString)

{

String digits = "0123456789abcdef";

String hex = new String();

--lengthOfString;

int i;

for (i = lengthOfString;i >= 0;--i)

{

double p = Math.pow(16, i);

double r = num / p;

int j = (int)r;

if (j >= 0 && j < digits.length() )

{

hex += digits.charAt(j);

num -= (double)j * p;

}

}

return hex;

}

// helper function to convert a double to a digit string with a specified length

static String toDigitString(double num, int lengthOfString)

{

String digits = "0123456789";

String hex = new String();

--lengthOfString;

int i;

for (i = lengthOfString;i >= 0;--i)

{

double p = Math.pow(10, i);

double r = num / p;

int j = (int)r;

if (j >= 0 && j < digits.length() )

{

hex += digits.charAt(j);

num -= (double)j * p;

}

}

return hex;

}

// generate random number

static void mbsrand1(String param, int bt[])

{

File inputFile = new File("keycoding.bin");

int i;

for (i = 0;i < bt.length;++i)

bt = 0;

try

{

FileInputStream stream = new FileInputStream("keycoding.bin");

byte tmp[] = new byte[bt.length];

stream.read(tmp);

for (i = 0;i < tmp.length;++i)

{

bt = (int)tmp;

}

stream.close();

}

catch(IOException e)

{

System.out.println("Could not read keycoding.bin");

}

byte byteParam[] = param.getBytes();

int i1;

for (i1 = 0;i1 < bt.length;++i1)

{

int i2 = 1024 - 2 * bt[i1] + (int)(byteParam[i1 % byteParam.length]) - i1;

if (i1 == 0)

{

bt[i1] = i2 % 256;

}

else

{

bt[i1] = (i2 + bt[i1 - 1]) % 256;

}

}

for (i1 = 30; i1 >= 0;--i1)

{

bt[i1] = (bt[i1] + bt[i1 + 1] + i1) % 256;

}

}

/*

static String mbRandom(boolean hex, String random, String param)

{

if (random.length() % 2 != 0)

throw(new NumberFormatException(new String("invalid random = " + random) ) );

int binfo[] = new int[32];

param += "?";

mbsrand1(param, binfo);

byte tmp[] = random.getBytes();

if (hex)

{

int i;

for (i = 0;i < random.length() / 2;++i)

{

int ch = binfo[i % binfo.length];

if (ch / 16 > 9)

{

tmp[i * 2 + 0] = (byte)(ch / 16 + 65 - 10);

}

else

{

tmp[i * 2 + 0] = (byte)(ch / 16 + 48);

}

if (ch % 16 > 9)

{

tmp[i * 2 + 1] = (byte)( (ch % 16) + 65 - 10);

}

else

{

tmp[i * 2 + 1] = (byte)( (ch % 16) + 48);

}

}

}

else

{

int i;

for (i = 0;i < random.length() / 2;++i)

{

int ch = (int)binfo[i % binfo.length];

tmp[i * 2] = 3 + 48;

if (i % 2 == 0)

{

tmp[i * 2 + 1] = (byte)( (ch / 16) % 10 + 48);

}

else

{

tmp[i * 2 + 1] = (byte)( ( (ch % 16) % 10) + 48);

}

}

}

String result = new String(tmp);

return result;

}*/

static String mbRandom(boolean hex, int length)

{

if (length % 2 != 0)

throw(new NumberFormatException(new String("mbRandom: invalid length") ) );

byte tmp[] = new byte[length * 2];

if (hex)

{

int i;

for (i = 0;i < length;++i)

{

double rnd = Math.random() * 255;

int ch = (int)(rnd + 0.5);

if (ch / 16 > 9)

{

tmp[i * 2] = (byte)(ch / 16 + 65 - 10);

}

else

{

tmp[i * 2] = (byte)(ch / 16 + 48);

}

if (ch % 16 > 9)

{

tmp[i * 2 + 1] = (byte)( (ch % 16) + 65 - 10);

}

else

{

tmp[i * 2 + 1] = (byte)( (ch % 16) + 48);

}

}

}

else

{

int i;

for (i = 0;i < length;++i)

{

double rnd = Math.random() * 10;

int ch = (int)(rnd + 0.5);

tmp[i * 2] = (byte)(3 + 48);

tmp[i * 2 + 1] = (byte)( (ch % 10) + 48);

}

}

String result = new String(tmp);

return result;

}

public static String mbRandomDigits(int length)

{

return mbRandom(false, length);

}

public static String mbRandomHex(int length)

{

return mbRandom(true, length);

}

static String mbRandom(boolean hex, String random)

{

if (random.length() % 2 != 0)

throw(new NumberFormatException(new String("invalid random = " + random) ) );

byte tmp[] = random.getBytes();

if (hex)

{

int i;

for (i = 0;i < random.length() / 2;++i)

{

double rnd = Math.random() * 255;

int ch = (int)(rnd + 0.5);

if (ch / 16 > 9)

{

tmp[i * 2] = (byte)(ch / 16 + 65 - 10);

}

else

{

tmp[i * 2] = (byte)(ch / 16 + 48);

}

if (ch % 16 > 9)

{

tmp[i * 2 + 1] = (byte)( (ch % 16) + 65 - 10);

}

else

{

tmp[i * 2 + 1] = (byte)( (ch % 16) + 48);

}

}

}

else

{

int i;

for (i = 0;i < random.length() / 2;++i)

{

double rnd = Math.random() * 10;

int ch = (int)(rnd + 0.5);

tmp[i * 2] = (byte)(3 + 48);

tmp[i * 2 + 1] = (byte)( (ch % 10) + 48);

}

}

String result = new String(tmp);

return result;

}

public static String mbRandomDigits(String random)

{

return mbRandom(false, random);

}

public static String mbRandomHex(String random)

{

return mbRandom(true, random);

}

public static String checkSum(String source)

{

if(source.length() % 2 != 0)

throw (new IllegalArgumentException("checkSum: odd length of source") );

int nBytes = source.length() / 2;

int nSum = 0;

int i;

for(i = 0;i < nBytes;++i)

{

byte tmp = getByteFrom2HexDigits(source.substring(i * 2, i * 2 + 2) );

Byte b = new Byte(tmp);

nSum += b.intValue();

}

byte c = (new Integer(nSum) ).byteValue();

byte inv = (new Integer(255 - c) ).byteValue();

String hex = String.format("%2x", inv);

source = hex + source;

return source;

}

public static String ascii2char(String strascii)

{

String tmp = "";

for (int i = 1; i < strascii.length(); i+=2)

{

tmp += strascii.Substring(i, 1);

}

return tmp;

}

}

[13789 byte] By [mASOUDa] at [2007-11-26 17:19:53]
# 1
The code as posted does not compile; were you able ot compile your program using javac? If so, then what was the exact command you used to try to run it?
jxca at 2007-7-8 23:47:52 > top of Java-index,Desktop,Runtime Environment...