Solved

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

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 36
jar file executable 12 51
couple of eclipse 5 35
HashTable highest marks enumeration alternative 9 37
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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…

813 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

12 Experts available now in Live!

Get 1:1 Help Now