Eclipse Projects
posted 21 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
Thanks.
posted 21 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
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
posted 21 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
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 ]
posted 21 years ago
U can add this class into default ,
-> Select project -> Class
In Wizard
- package is empty (default)
- fill class name : NameOfClassInDefaultPackage
- OK
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
David Bridgewater
author
Posts: 44
posted 21 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 ]
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
posted 21 years ago
That's the plan to try this morning! Had thought of it, but haven't tried it yet.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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 |









