• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why Developers Should Not Write Programs That Call 'sun' Packages
 
Abhra Kar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Abhra Kar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic