Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
624 views
in Technique[技术] by (71.8m points)

java - Package com.sun.org.apache.xml.internal.security.utils.Base64 does not exist

I am using NetBeans 7.0.1 and JDK 1.6 Update 24 and when importing the package com.sun.org.apache.xml.internal.security.utils.Base64 to encode a password hash:

u.setPassword(Base64.encode(digest(password)));

When compiling however, I get the following error:

(omitted)RegistrationController.java:8: package com.sun.org.apache.xml.internal.security.utils does not exist
import com.sun.org.apache.xml.internal.security.utils.Base64;

(omitted)RegistrationController.java:94: cannot find symbol
symbol  : variable Base64
location: class RegistrationController
    u.setPassword(Base64.encode(digest(password)));
2 errors

I have read several other questions regarding the same problem but all deal with packages that are not part of the JDK whereas this is (rt.jar). Code Assists works on the type and expanding the jar reveals both the source code and binary are in fact present as well.

I have tried cleaning the project, rebuilding it, copying the source files over to a brand new Enterprise project and running NetBeans as Administrator, all to no avail. Any clue on how to solve this very much appreciated!

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

com.sun.* classes are not part of the Java API, and you shouldn't be relying on them. I would suggest using Apache Commons Codec to do Base64 encoding instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...