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

stonar96
  • 1,359
  • 2
  • 11
  • 39
  • a previous post can help http://stackoverflow.com/questions/17408769/how-do-i-resolve-this-java-class-not-found-exception – AurA Nov 04 '15 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. – stonar96 Nov 04 '15 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. – prashant thakre Nov 04 '15 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? – stonar96 Nov 04 '15 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. – OneCricketeer Nov 04 '15 at 12:34
  • @cricket_007 okay, i will add them when I am at home, thx for help! – stonar96 Nov 04 '15 at 13:40

1 Answers1

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.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 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 Nov 05 '15 at 18:54
  • @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 :) – OneCricketeer Nov 05 '15 at 19:20
  • 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! :) – stonar96 Nov 05 '15 at 20:07