3

I have a Java project, where I collect all my util classes and I want to use them in other projects. So I have tried to add the utils project to the Java Build Path of the project where I want to use the utils. But when I use them, I get a ClassNotFoundException at runtime, but no compile errors.

How can I solve this?

Edit: Screenshots

enter image description here enter image description here

Edit: Solution:

enter image description here

6
  • a previous post can help stackoverflow.com/questions/17408769/… Commented Nov 4, 2015 at 11:51
  • but i added an existing project from the work space, and not a jar file. the classes i use, all exist. i can import them and use them without compile errors. Commented Nov 4, 2015 at 11:56
  • Did you check your class is recompiling? looks like its not generating class.Just put System.out.println and clean the project followed by build and check whether you have class for it or not. Commented Nov 4, 2015 at 11:56
  • what should i print? my application works until it comes to the part where i use the util classes. And what can i do that it generates the class? Commented Nov 4, 2015 at 12:15
  • Maybe add some screenshots of your buildpath. You may be simply referencing the other project at compile time, but it isn't being included at runtime. Commented Nov 4, 2015 at 12:34

1 Answer 1

1

So in your ChunkPlots folder on you filesystem, look for a .classpath file and verify you have a line that looks like

<classpathentry combineaccessrules="false" kind="src" path="/BukkitUtils"/>

I've done something like this before and that line is in that file for me. I might have used the Libraries tab to add the project. I don't really remember and I don't use Eclipse anymore.

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

3 Comments

I have this line already in my .classpath file. I already found a working solution for my problem. Solution: When I export the project ChunkPlots to a jar file i just have to add a check into the box of the BukkitUtils Project. (See question)
@stonar96 - Ah. Didn't realize you were additionally exporting the projects as a JAR, I thought you were just running them directly from Eclipse. Glad you figured it out :)
Didn't thought that this is importent to mention. I didn't try running the project from eclipse, but it would probably work fine. The problem was that eclipse didn't put the classes from BukkitUtils into the jar file. Thank you for your help! :)

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.