Running a Java Program from jar file not working if another package is used, classpath set
<p>I am importing one class(it is not there in the default jvm) from one jar package and using it in another package. <em>like</em> I have a class program1.class in package package1 and I am importing this class from another programme program2 in package package2.</p>

<pre><code>package package1;
public class Program1
{
    public String sayHello()
    {
        return "Hello world";
    }
}
</code></pre>

<p>and importing this class in </p>

<pre><code>package package2;
import package1.Program1;
public class Program2
{
    public static void main(String args[])
    {
        System.out.println("I am in programme2");
        System.out.println("I am in programme 1"+new Program1().sayHello());
    }
}
</code></pre>

<p>I have compiled the program1 and packaged it by
    javac -d . Program1.java
    jar cf Pack1.jar package1</p>

<p>and second programme by
    javac -d . Program2.java
    jar cfm Pack2.jar Manifest.txt package2</p>

<p>my manifest file is </p>

<pre><code>Main-Class: package2.Program2
</code></pre>

<p>now I am running the programme as
    java -classpath path/to/Pack1.jar -jar Pack2.jar</p>

<p>it is giving me error as:
    I am in Program2
    No class def found error Package1/Program1</p>

<p>If I am running it by specifying the  Class as
    java -classpath path/to/Pack1.jar;path/to/Pack2(UnJar'ed) Pack2.program2
it is working which is very strange</p>

<p>Means there is a different between specifying the class file containing the main and specifying the jar file of the program.
I have already made sure that I have set Main-Class is set correctly in Manifest.mf, moreover the classpath for pack2 is also specified
So why this error</p>
