I have a java project which includes settings, bin, src, .classpath, .project.
I am trying to r开发者_StackOverflow社区un this project in eclipse, so I import this project. Now in eclipse I can see src
which includes (default package)
and com.mjm.transactions
,(default package)
includes all .java files, in com.mjm.transactions
it is supposed to exist all .class files in transactions
folder which I cant see in eclipse, and so there is error on import com.mjm.transactions.myclass;
of cannot be resolved.
I also used 'Add class folder' in myProject->properties->Library ->myclass.zip but it is not importing myclass.class
, if I use organize imports in eclipse it resolves this error and adds Reference Libraries/myClass.zip/default package/myclass.class
but now giving me error Exception in thread "main" java.lang.NoClassDefFoundError: com/mjm/transactions/myclass when I run it.
Where is the problem, pls help me out. Thanks
If your source files are in the com.mjm.transactions
package, then they should be placed in src/com/mjm/transactions
in order for Eclipse to recognize that they are part of the com.mjm.transactions
package. Move all the .java
files in the default package to the com.mjm.transactions
package within Eclipse and it should be OK.
Make sure that you define the Java build path. Keep Output Output folder to /bin. All the compiled files (.class files) should exist in the bin folder. so that those will be available in classpath.
精彩评论