Problem:
--------
I'm trying to create an executable jar file. I can do so as long as
I don't use the "package" statement in my source code. Once I put the
package statement in I can't execute the jar file.
Here is the criteria of what I am working with:
-----------------------------------------------
Working directory:
------------------
/home/emartin/testArea
Classpath is set to:
--------------------
export CLASSPATH=$CLASSPATH:.:/usr/java/lib/tools.jar:/usr/java/lib/dt.jar:/usr/java/lib/htmlconver
ter.jar:/home/emartin
Source file name: test.java
Contents of test.java :
--------------------------------
package testArea;
import java.io.*;
import java.net.*;
import java.util.*;
public class test
{
public test (){}
public static void main (String[] args)
{
try
{
System.out.println( "test.main() Hey there!");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
--------------------------------
Contents of ManifestHeader.txt :
--------------------------------
Main-Class: testArea.test
Build Procedure:
----------------
javac test.java
Builds a test.class file which runs fine as follows:
----------------------------------------------------
java testArea.test
Build an executable jar file using the manifest file as follows:
----------------------------------------------------------------
jar cmf ManifestHeader.txt test.jar test.class
Execute the jar file as follows:
--------------------------------
java -jar test.jar
I get the following error when trying to execute the jar file:
--------------------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError:
testArea/test
It's acting like it can't understand what the CLASSPATH is set to.
I've tried various combinations of compiling and running with
the -classpath arguement to javac and java, respectively.
But nothing seems to work.
Has anyone else had problems with this or am I missing something
very fundamental?
Regards,
--Eric