Solved

Alternative for RemoteValue.class in rt.jar of jre1.1.6

Posted on 1998-10-29
2
413 Views
Last Modified: 2008-02-01
We used the remoteValue class file in our appln for conerting from & to Hex values. But when the appln is run using rt.jar it says classDefNotfound error for this class.
Is there an alternate class file in rt.jar which could be used for similar purposes.
0
Comment
Question by:vram
2 Comments
 
LVL 2

Accepted Solution

by:
shchuka earned 50 total points
ID: 1226672
What are you converting to and from Hex values?  Why can't you simply write two short static methods to do the conversion?  Below are the methods:

//--------This one will convert a long to a hex-----------
public static String longToHex(long num) {
    String[] digs = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};
    String res = new String();

    while(num > 0) {
        res = digs[(int)(num % 16)] + res;
        num /= 16;
    }

    return res;
}

//--------This one will convert a hex to a long-----------
public static hexToLong(String hex) throws NumberFormatException {
    long res = 0;
    long dd = 0;
    String tmp = hex.toUpperCase();

    for(int i=0; i<tmp.length; i++) {
        long dig = (long)tmp.charAt(i);
        if(dig >= 65 && dig <= 70)
            dig -= 55;
        else if(dig >=48 && dig <= 57)
            dig -=48;
        else
            throw new NumberFormatException("Invalid hex number: " + hex);
        res = res * 16 + dig;
    }

    return res;
}

0
 
LVL 4

Expert Comment

by:evijay
ID: 1226673
Why cant you use the methods parseLong in java.lang.Long class

parseLong

 public static long parseLong(String s,
                              int radix) throws NumberFormatException

    Parses the string argument as a signed long in the radix specified by the second argument. The characters in the string must all be
    digits of the specified radix (as determined by whether Character.digit returns a nonnegative value), except that the first
    character may be an ASCII minus sign '-' to indicate a negative value. The resulting long value is returned.

    Parameters:
        s - the String containing the long.
        radix - the radix to be used.
    Returns:
        the long represented by the string argument in the specified radix.
    Throws: NumberFormatException
        if the string does not contain a parsable integer.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now