Package to jar in eclipse
Solution 1
@trideceth12 I just tested exporting a sample package in my eclipse. and my folder structure works fine. not sure why yours is not working properly. you should check all your export settings. here's what mine looks like, and it exports fine.
Solution 2
when you create jar file using eclipse choose the export option ,in your jar creation wizard chosse your necessary folder ,then finish, for see here
Solution 3
Look like your Java source is in Default package only. If you want to use this kind of import statement, considering moving the jar file to:
pkg/nme/with/dots
jsj
Updated on June 13, 2022Comments
-
jsj almost 2 years
UPDATE: Don't worry. User Error. Would delete the question but cant with answers.
I am trying to use eclipse to create a jar of packages, not a runnable jar, which I can import into another project.
So far I have done this:
- Create a new project
- Create a package in that project (pkg.nme.with.dots)
- Create a class in that package
- Export -> Java -> Jar
The resultant .jar file has only one directory
META-INF
, and three files.project
,.classpath
, andMyClass.class
.If I try to
import pkg.nme.with.dots.MyClass;
I get a package not found error, despite adding the full path of the jar to my CLASSPATH.I tried adding the jar as an external lib in eclipse but it is still not recognised.
Obviously I have exported it into a format that can't be
import
ed. How do I export it correctly?