I have a java project which includes settings, bin, src, .classpath, .project.
I am trying to run 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.transactionspackage, then they should be placed insrc/com/mjm/transactionsin order for Eclipse to recognize that they are part of thecom.mjm.transactionspackage. Move all the.javafiles in the default package to thecom.mjm.transactionspackage within Eclipse and it should be OK.