• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Accessing non-packaged classes (urgent)

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My classes are being compiled into a package. But it uses a class which is not in a package (ie: no package statement). I have set the class path correctly so as to point to the directory containing the class file but still the compiler is not able to find that class. Is there a way to access this class that has no package from a packaged class?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At first I answered :
Are you using public on the classes in the default package?
But now I found
this
Could therefore mean that you are out of luck.
-Barry
[ October 04, 2002: Message edited by: Barry Gaunt ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my experience, you cannot do that.
I'm not exactly sure why Java was designed to not allow such a thing, but it wasn't. IBM's compiler, jikes, will also not allow you to do that.
[ October 05, 2002: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember right... you used to be able to do it by importing the packageless class specifically ("import TheClass;"). But as of JDK 1.4 it is no longer allowed by javac.
 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Snigdha !
Try pointing the system "path" variable directly to the class.
Leena
 
I don't always make ads but when I do they're tiny
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic