• Post Reply Bookmark Topic Watch Topic
  • New Topic

Do I need to delete source files ?  RSS feed

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

A very simple example:

In current directory ~home/Desktop/A.java


In current directory ~home/Desktop/B.java


In current directory ~home/Desktop/Bee.java


Then I compile files A.java and B.java:

javac -d . A.java B.java

so new directory structure has been created in current ~home/Dekstop directory.

Now when I want to compile Bee.java, I got this error:

javac Bee.java

Bee.java:13: cannot access A
bad class file: ./A.java
file does not contain class A
Please remove or make sure it appears in the correct subdirectory of the classpath.
A.main(null);
^
1 error

When I delete source files from current directory ~home/Desktop it compiles fine !

Could anybody explain that to me please ? Why do I need to put source
files in corresponding directories as well ? Why compiler can't use
class files provided ?

Thanks,

Adrian
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,first you need to create one folder whose name is same as your package name.then save A.java and b.java files in this folder,also after compilation its necessary to store class files(A.class and B.class) in the same package.after this your Bee.java where you are going to import the package should be outside your package.your problem must get solved.try it.

Amit RajeSaste.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!