1

I have created a class in java i want to reuse the code just like java.lang has build in function without my project opened all the time how to do that.How to add my class to java library.

3 Answers 3

3
  • Make a jar file of your project.
  • Add the jar file to build path of the project in which you want to use your first class
  • Import the class in new project.
Sign up to request clarification or add additional context in comments.

Comments

0

Hopefully I understood your question right. Compile your code into a jar file and add it to your system's LD_LIBRARY_PATH or your consumer project's build CLASSPATH.

Comments

0

If it is just simply using your class then you can just import it from the package.

If your class is in other package(folder) you can import it like this:

  import packageName.className;

If your class is in same package you don't have to import the class to use it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.