Shree Java

Greenhorn
+ Follow
since Jun 28, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shree Java

I checked the sample.jar (opened in winzip)and it has Test.class under the directory "Test".

I have executed the command:
jar -cmf mainClass.txt sample.jar *.class
from the directory Test.
17 years ago
Hi,

Thanks for the reply.

I have maintained the directory structure.
And when unjared, it works fine. But I am facing problem when trying to execute from the jar file.
17 years ago
I have a class called JarTest which is in the package Test:

package Test;

import java.io.*;

public class JarTest {
public final static void main( String[] args )
{
System.out.println( "Hello Readers" );
}
}

I have compiled and tested it . It is working fine. Then I created an exceutable jar file using the command:

jar -cmf mainClass.txt sample.jar *.class

The contents of mainClass.txt is Without the double quotes mentioned below)

"
Main-Class: Test.JarTest

"

It gives me the following error when I running the program from excutable jar file:

java -jar sample.jar

Exception in thread "main" java.lang.NoClassDefFoundError: Test/JarTest

The same stuff worked when I did not specify the package "Test" for class "JarTest".

Please help.
17 years ago