I have the following directory layout: The program folder contains java, class, and pack folders and my current location is program/java, which contains a.java and b.java files. Initially class and pack contains nothing.
b.java
package comm.domm;
public class b
{
public void bFu()
{
System.out.println("b function");
}
}
a.java
package com.dom;
import comm.domm.*;
class a
{
public static void main(String args[])
{
(new b()).bFu();
System.out.println("Utsab");
}
}
Now, from program/java issue the following commands
javac -d ../pack b.java
javac -cp ../pack -d ../class a.java
Which creates comm/domm under pack and places b.class in program/pack/comm/domm and creates com/dom under class and places a.class in program/class/com/dom
now from the same current directory I issue,
java -cp ../class;../pack com.dom.a
Which does not work, it can locate a.class but not b.class(b.class is required by a.class, as described in the source code) this time but while compiling a.java using
javac -cp ../pack -d ../class a.java
It could locate b.class and produced a.class, then why b.class is not found when I tried to run a.class?? How it can be found? b.class is found during compilation but not at run time, why??