Importing a zipped package in Eclipse
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I have a package zipped using Winrar, and want to import it using Eclipse IDE. I did that by using the "Import" function when you right-click on your project's name. But, when I create a new class, and type, say:
import element.*;
I get an error.
What should I do?
Thanks.
import element.*;
I get an error.
What should I do?
Thanks.
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What error do you get? The more details you tell us, the better we can help you. Is the error that it can't find the package named "element"?
If you want to use classes from one project in another project, you need to set the Java build path in the project where you want to use the other project: right-click the project, select Properties, select Java Build Path, Projects, and add the other project there.
If you want to use classes from one project in another project, you need to set the Java build path in the project where you want to use the other project: right-click the project, select Properties, select Java Build Path, Projects, and add the other project there.
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Be careful with using WinRAR - it uses (by default) a compression mechanism that is not compatible with the compression algorithm used for JAR files. Thus Java code, such as Eclipse, will not be able to access the contents.
Also, what "Import" function did you use? There are dozens of them. Was it "Archive File"?
Also, what "Import" function did you use? There are dozens of them. Was it "Archive File"?
posted 17 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It sounds like you're confusing Eclipse code imports with java imports. There is a LOT of difference!
The eclipse import function copies files into you project. It does NOT simply make a references to the ZIP file, it actually unzips it into your project workspace. If you change or delete the original ZIP file, the project won't notice the difference, becausse it works only with the unzipped copies.
The Java import directive, on the other hand doesn't know or care about Eclipse. All it cares about is if the compiler can find the class(es) being imported in the compile classpath. Which is the same a the editor search path in the Eclipse Java editor/compiler framework. That classpath is defined in the project's Java build properties dialog.
So to find a class that's being imported via Eclipse, you have to import the class, either in object class form or as compilable source using the Eclipse import in order to copy it into the project workspace. Then, if it's java source, you have to either place it in a project source directory or designate the directory subtree that it was imported into as a project source directory. Finally, you have to make sure that the classfile itself is in the project's class path.
Finally, if you worked for me, you'd be required to make sure all that stuff could build with Ant or maven so that Eclipse wouldn't be the only way you could build a project. But that's because I have very strong opinions on staying IDE-independent.
In fact, I just had to disappoint a potential customer because I couldn't build an IDE-dependent project for him so that I could fix some critical bugs. The IDE was antique and to set up the old environment would have cost me more than he could afford to pay. If there'd been an old Ant script, there wouldn't have been a problem.
The eclipse import function copies files into you project. It does NOT simply make a references to the ZIP file, it actually unzips it into your project workspace. If you change or delete the original ZIP file, the project won't notice the difference, becausse it works only with the unzipped copies.
The Java import directive, on the other hand doesn't know or care about Eclipse. All it cares about is if the compiler can find the class(es) being imported in the compile classpath. Which is the same a the editor search path in the Eclipse Java editor/compiler framework. That classpath is defined in the project's Java build properties dialog.
So to find a class that's being imported via Eclipse, you have to import the class, either in object class form or as compilable source using the Eclipse import in order to copy it into the project workspace. Then, if it's java source, you have to either place it in a project source directory or designate the directory subtree that it was imported into as a project source directory. Finally, you have to make sure that the classfile itself is in the project's class path.
Finally, if you worked for me, you'd be required to make sure all that stuff could build with Ant or maven so that Eclipse wouldn't be the only way you could build a project. But that's because I have very strong opinions on staying IDE-independent.
In fact, I just had to disappoint a potential customer because I couldn't build an IDE-dependent project for him so that I could fix some critical bugs. The IDE was antique and to set up the old environment would have cost me more than he could afford to pay. If there'd been an old Ant script, there wouldn't have been a problem.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
| I found a beautiful pie. And 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 |











