This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Access Restriction error when try to use Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Access Restriction error when try to use "sun.net.util.IPAddressUtil" " Watch "Access Restriction error when try to use "sun.net.util.IPAddressUtil" " New topic
Author

Access Restriction error when try to use "sun.net.util.IPAddressUtil"

Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 112
Hi,
I want to check a string suppose "101a:1450::" is Ipv6Address or not. To test that I used IPAddressUtil.isIPv6LiteralAddress("101a:1450::") , and to do this I had to import sun.net.util , but when i write the code in eclipse it shows an error like -------
Access restriction: The type IPAddressUtil is not accessible due to restriction on required library D:\Java\jdk1.5.0_05\jre\lib
\rt.jar


how to solve this error , do I have to add any permission somewhere? Please suggest.

Thanks in advance
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3036
    
    4

Interesting...

My guess is that you have two different versions of the rt.jar file in your classpath. And whichever one you are trying to get IPAddressUtil out of is the second one being loaded. It is either that or another JAR has a sun.net.util.IPAddressUtil class defined in it and is causing the same conflict. Check your classpath, make sure you know exactly what jars and libraries are being loaded.


Steve
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12924
    
    3

Why Developers Should Not Write Programs That Call 'sun' Packages


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 112
Thanks for the link ,I will try to avoid this package in future but to solve this problem for now I checked the classpath,
only one rt,jar is set, so there is no conflict .Do I have to add any permission for this in java.policy file under "\jdk1.6.0\jre\lib\security"
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 8143
    
  52

Abhra Kar wrote: but when i write the code in eclipse it shows an error like -------
Access restriction: The type IPAddressUtil is not accessible due to restriction on required library D:\Java\jdk1.5.0_05\jre\lib
\rt.jar



You see that error at runtime or do you see that as a red error mark that Eclipse shows up in the code? If it's an runtime error, can you post the entire exception stacktrace? By the way, what happens when you don't use an IDE to compile or run that code?

[My Blog] [JavaRanch Journal]
Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 112
I see that as a red error mark that Eclipse shows up in the code, but when I run with out eclipse(simply write in a Test class in notepad) then it's compile and run properly, thanks for the suggestion, what can be the error in eclipse

Thanks
Abhra
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 321
Try googling eclipse "is not accessible due to restriction on required library" and you'll get a number of hits giving reasons for the warning and how to get rid of it.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Access Restriction error when try to use "sun.net.util.IPAddressUtil"
 
Similar Threads
Forwrad Referncing
how to access com.sun.management.OperatingSystemMXBean in eclipse
forward referencing doubt
OperatingSystemMXBean.getTotalPhysicalMemorySize()
Complete Java 2 Cert Study Guide - Distributed Notification