Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 1998-10-29
2
417 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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…

860 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