• 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

Import in Java

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'am studying the sun tutorial for the java language, and have a problem with an import in eclipse.

From the Sample below there is an import which don't work in eclipse.



http://java.sun.com/docs/books/tutorial/ui/overview/PasswordStore-1.0-src.zip

Could anyone tell me how to get that import work?

Thank you very much

kind regards
Lars
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lars,

Welcome to JavaRanch.

From the Sample below there is an import which don't work in eclipse.

What error do you get?
 
Lars Dold
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jan,

Sorry forget to mention the error:

Access restriction: The type Util is not accessible due to restriction on required library /usr/lib/jvm/java-6-sun-1.6.0.12/jre/lib/rt.jar

Hope that clears the problem.

thank you

kind regards

Lars
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lars, welcome to JavaRanch.

That import is strange. You should not normally import anything from com.sun.* packages - those classes are not part of Java's standard API and may not be accessible or even present in all versions of the JDK.

In which tutorial did you find the code that uses that import?
 
Lars Dold
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

the demo is described here:
http://java.sun.com/docs/books/tutorial/ui/overview/demo.html

And can be downloaded here:
http://java.sun.com/docs/books/tutorial/ui/overview/PasswordStore-1.0-src.zip

(Edited the link in my previos post)

Error in Class:
/passwordstore/swingx/LookAndFeelMenu.java
line 8

thanks

kind regards

Lars
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to IDEs forum because this is an IDE problem.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another possible explanation, which is why I think it is an IDE-related problem:

The databases or properties files which Eclipse uses contain a larger "stock" of classes than the usual Sun/Oracle API. There are obviously several classes called Util. When you click Util and ctrl-space or whatever you use to expand the name, Eclipse gives you a drop-down list with the possibilities in alphabetical order. You might want java.something.somethingelse.Util, but com....Util comes out first because "com" comes before "java" in the alphabet. so what has happened is that you have seen "Util" on the drop-down list and clicked on that, whereas the Util you really wanted was farther down the list.

I have made that mistake many times myself.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If they require you to use the com.sun package, they ought to tell you how to download it and add it to your classpath.
 
Lars Dold
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have changed the import to that:



because there is no entry with CORBA.Util

And now it works!

Thanks to all of you, for your good help

kind regards

Lars
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, and example with "com.sun.corba.anything" is probably horribly old and likely obsolete. That's because CORBA was integrated into the stock JVM somewhere about Java 1.2 or so, and at that point, the classes were replaced with a similar-but-not-identical set of standard classes, which should be in the javax and/or java package trees.

Of course, CORBA all but died in 2007 as web services has pretty much supplanted it. Eventually it might make a comeback, since there are unique and desirable features about CORBA, once you get past its limitations (the original spec had little security and didn't play well with firewalls).
 
reply
    Bookmark Topic Watch Topic
  • New Topic