sun.misc.base64

J

Janna

Can anyone tell me what jar or package I need to include sun.misc.Base64.*
dependencies? I want to use this package in an application being developed
in Eclipse, but I don;t know where it exists (This has to be developed under
JDK 1.4.2). Thanks guys.
 
M

Marcelo Morales

Janna said:
Can anyone tell me what jar or package I need to include sun.misc.Base64.*
dependencies? I want to use this package in an application being developed
in Eclipse, but I don;t know where it exists (This has to be developed under
JDK 1.4.2). Thanks guys.

On the JDK 1.4.2, both sun/misc/BASE64Encoder and sun/misc/
BASE64Decoder come in the standard distribution, on a jarfile called
classes.jar.

However... you should not rely on these classes. See:

http://java.sun.com/products/jdk/faq/faq-sun-packages.html

Maybe other JREs don't include such classes.... ibm? gcj? ..

Try something like apache jakarta commons codec for a ever compatible
implementation for Base64.

Best regards.
 
A

Arne Vajhøj

Janna said:
Can anyone tell me what jar or package I need to include sun.misc.Base64.*
dependencies? I want to use this package in an application being developed
in Eclipse, but I don;t know where it exists (This has to be developed under
JDK 1.4.2). Thanks guys.

Using internal Java classes from SUN is not recommended.

Use the supported Base64 in JavaMail.

public static String b64encode(byte[] b) throws MessagingException,
IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream b64os = MimeUtility.encode(baos, "base64");
b64os.write(b);
b64os.close();
return new String(baos.toByteArray());
}
public static byte[] b64decode(String s) throws
MessagingException, IOException {
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes());
InputStream b64is = MimeUtility.decode(bais, "Base64");
byte[] tmp = new byte[s.length()];
int n = b64is.read(tmp);
byte[] res = new byte[n];
System.arraycopy(tmp, 0, res, 0, n);
return res;
}

Arne
 
R

Roedy Green

Neither should be recommended when a solution exist within
javax classes.

Is Javamail now bundled? It would be a pretty big jar to include in a
distribution just to get one class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top