• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to use class inside the default package inside other packages!!

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using Eclipse 3.2 and I have created a project with some package structure along with the default package. I have one class in default package (DefaultClass.java) and I want to make the use of that class in any of the package (for e.g. com.my.test.MyClass) . Whenever I try to make the use of the class which is default package , its giving me compile time error . Its not able to reconise the class in default package. Is there anything that I am missing . I even tried to put import statement (import DefaultPackage.java) . But still the class is not getting reconised . Can anybody please tell me the solution for the same.
Thanks in advance,
Samir
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The import of the default package is forbidden since Java 1.4 (I think...). So you have to change your project settings to make it comply to Java 1.3 (Project/Properties/Java Compiler/JDK Standard : 1.3). Or even better, don't use the default package !
 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Christophe
Thanks for the prompt reply . I just cant put my class inside any other folder. And moreover I don't want to shift to 1.3 . Is there any other way by which I can access the class put in the default folder in other folders
Thanks
Samir
 
Sheriff
Posts: 28333
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by samir ware:
I just cant put my class inside any other folder.

Of course you can. And if you want to use it in classes that are in a package, you will. That's the rule, as you know now.
 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,
I do admit that I can put my class in any other folder. But that class has one native method which is implemented in C++ . If I put that class in any of the folder,I will have to make the change that DLL (JNI compulsion ) which I want to avoid. Thats why I insist to put my class in the default folder as the DLL is made, keeping in mind that the class will always be in default folder.
Thanks
Samir
 
Marshal
Posts: 79987
399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't have it both ways; you can either import that class into the rest of the Java code, or you can leave the native code unchanged. But not both.
 
What are you doing in my house? Get 'em tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic