I have file structre like this :
Now when i try to compile SomeFile.java using the command
it compiles fine.
But when i try to compile SomeOtherFile.java using the command
it gives the error
package one doesn't exist
After some study i got to know that this can be the problem associated with classpath....,but still i am not able to fix it.
Please suggest some remedy.
This is a classpath issue. The classpath is the folder under which all of your packages and classes can be found. You have two packages, one and another. These two packages are both in C:\javapractice, so C:\javapractice needs to be in your classpath. Here is how you do it:
1: Navigate to C:\javapractice\ to do all your compiling (the root of your classpath).
2: Type in javac -cp . one\SomeFile.java -- the -cp sets the classpath, then a space then a period. The period means 'this folder'. So -cp . means 'set the classpath to the current folder'
3: Type in javac -cp . another\SomeOtherFile.java -- since -cp was set to C:\javapractice, the compiler knows to start looking there for one.SomeFile.class