Package for jar in eclipse

UPDATE: Do not worry. User Error. He would delete the question, but could not answer.

I am trying to use eclipse to create a jar of packages, rather than a runnable jar, which I can import into another project.

So far I have done this:

  • Create a new project
  • Create a package in this project (pkg.nme.with.dots)
  • Create a class in this package
  • Export → Java → Jar

The resulting .jar file has only one META-INF and three .project , .classpath and MyClass.class .

If I try import pkg.nme.with.dots.MyClass; , I get a package error not found, despite adding the full path to the jar in my CLASSPATH.

I tried to add the jar as an external library in eclipse, but it is still not recognized.

Obviously, I exported it to a format that import ed could not be. How to export it correctly?

+4
source share
3 answers

@ trideceth12 I just tested exporting a sample package in my eclipse. and my folder structure is working fine. not sure why your not working properly. You must check all export options. here is what mine looks like and it looks great. enter image description here

+4
source

when you create a jar file using eclipse, select the export option, in your jar creation wizard run your desired folder, then finish to see here

+3
source

See that your Java source is only in the default package. If you want to use this type of import statement, consider moving the jar file to:

 pkg/nme/with/dots 
+1
source

All Articles