Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

679 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