3

Hi I made one jar file with 3 classes.They work fine they are supporting file for getting HXM data.Now when i made jar i want to use it in my next project.I imported it and now it is in referenced libraries.But i can not find how can i use the libraries. in old project from i take the 3 .class file they have the paths: sk.csabi.hxm.*

but now how can i import and use them?

thanks

4
  • possible duplicate of How should i use a jar file ? Commented May 1, 2011 at 16:48
  • oh thanks i will check it if it is i delete my post Commented May 1, 2011 at 16:51
  • i need eclipse variant, it is not good for me Commented May 1, 2011 at 16:57
  • possible duplicate of Using java library in eclipse Commented May 1, 2011 at 17:12

1 Answer 1

4

Your question isn't very clear but it seems like you're asking how to add the JAR to your project classpath in Eclipse.

What you're looking to do is add the libraries to your project's build path (the class path that will be used while compiling). In Eclipse, you can do this by right-clicking your project and choosing Properties (or hitting [Alt]+[Enter] when the project is selected in Project Explorer, Navigator or Package Explorer views) and then Java Build Path from the sidebar and the Libraries tab where you can add JARs.

Note the difference between Add JARs and External JARs is that External JARs will add an external dependency in your project since the absolute path to the JAR on your filesystem will be put into your project's configuration. With Add JARs you can select JARs from within your workspace.

I find it to be a good practice to create a lib folder (at the same level as my src folder) and put all my JARs in there and then add them to the build path with the Add JARs option. This makes the project portable since there are only relative paths referring to resources within the project rather than absolute paths or resources from other workspace projects.

Sign up to request clarification or add additional context in comments.

7 Comments

and mazbe the problem is there the package name is (default package)
'ok but how can i import it to activity' What do you mean? An Android Activity is just another Java class - you would import other classes just as you would anywhere else, use the import statement: import sk.csabi.hxm.*.
'there the package name is (default package)' - I thought you said the package of the classes that you wanted to use was sk.csabi.hxm?
it where at the project where from the classes are, but when i created jar it created default package
That doesn't seem possible to me unless you've compiled the classes and then JARed the .class files without putting them into the correct folder hierarchy - on other words, you JAR has been built incorrectly. How did you create the JAR?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.