• 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:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Eclipse Projects

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone have experience using Eclipse projects to accomplish accessing code in the default package from code in a named package? Would this sort of task be covered in the book being discussed this week?

Thanks.
 
author
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was so intrigued by the question I tried it out.
Looks like all you need to do (within an Eclipse project) is to write (in the accessing class)

package whateverpkg;

import NameOfClassInDefaultPackage;

public class ClassInWhateverPkg {
private NameOfClassInDefaultPackage instanceVar;
// etc.
}

i.e. import the class you want to use with no prefix (which it wouldn't have 'cos it's in the default package...)

But I'm intrigued... why would you want to do this, or is it purely an academic question? Or have I completely missed the point?

Yrs,

David.
[ June 23, 2004: Message edited by: David Bridgewater ]
 
Mary Taylor
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to do this because some code I need to utilize was developed in a default package structure entirely separate from the package structure that I am working with. It's not an academic exercise.

How did you add the NameOfClassInDefaultPackage to the project? That seems to be the problem. I even tried making two projects, one with the classes in a package and the other with the classes in the default package. I've tried including one project as a dependency of the other. Currently, I've included both directories in the same project.

It has proven to be such a challenge that we plan to put those classes that were developed in a default package into a package.
[ June 23, 2004: Message edited by: Betty Schwartz ]
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How did you add the NameOfClassInDefaultPackage to the project?



U can add this class into default ,
-> Select project -> Class
In Wizard
- package is empty (default)
- fill class name : NameOfClassInDefaultPackage
- OK
 
David Bridgewater
author
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Betty,

I see where you're coming from now.

I can't make two projects co-operate (i.e. have a class in one project see a default package class in the other project). Like you, I have the other project in the first project's class path; but that doesn't seem to do the trick.

As long as there are no naming collisions, I would import (File|Import from your zip or jar file or naked file system) your non-packaged classes directly into the project in which you want to use them.

I'm assuming you have no source? If you did, I would use the Eclipse Refactor | Move facility to get those suckers into a named package at the first opportunity.

Hope this helps -

Best of luck,

David.
[ June 24, 2004: Message edited by: David Bridgewater ]
 
Mary Taylor
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I would use the Eclipse Refactor | Move facility to get those suckers into a named package at the first opportunity.



That's the plan to try this morning! Had thought of it, but haven't tried it yet.
 
That feels good. Thanks. Here's a tiny ad:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic