• Post Reply Bookmark Topic Watch Topic
  • New Topic

Access restriction error in decryption code  RSS feed

 
Adam Szewczyk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am getting error message on Java code that was developed by someone else and is supposed to work.

the error message is as follows:
Access restriction: The type 'BASE64Decoder" is not API (restriction on required library '/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rd.jar')
I am using eclipse. How should I trouble shoot this error? Thanks.
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Don't know. Start by finding where that Base64 class is. Have you added it to your classpath? Where is that openJDK file? Is it in your PATH?
Why are they using classes whose name starts with sun? They were experimental and may be removed. You may have to look for another base 64 class. Start looking here.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This happens because you are using the class sun.misc.BASE64Decoder, which you are not supposed to use.

Classes in sun.* and com.sun.* packages are not part of the public API of the JDK and are subject to change in any new Java version or update. Despite this, people are sometimes still using sun.* classes, such as the programmer who wrote this code.

In Java 8, a check has been added to Java to stop people from using these classes. That is why you are now getting an error.

The good news is that in Java 8 a new public API for Base 64 encoding / decoding has been added, the class java.util.Base64.

You have to change that code to use that new class instead of sun.misc.BASE64Decoder.
 
Adam Szewczyk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I replaced the code line:
dec = new sun.misc.BASE64Decoder().decodeBuffer(cryptic);
with new code line:
dec = new java.util.Base64().decodeBuffer(cryptic);
Unfortunately, it does not work.
What is wrong with it?


The complete listing of this code is from
https://github.com/dwwoelfel/opensourcephysics/blob/master/src/org/opensourcephysics/controls/Cryptic.java
From this textbook,
http://www.opensourcephysics.org/webdocs/programming.cfm?t=Overview
 
Paweł Baczyński
Bartender
Posts: 2077
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at Base64 javadoc.

Does Base64 have decodeBuffer method? Does it even have a public constructor?

Also, read this, please.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!