pacaking J2SE app into a Jar-file and executing them from Oracle9i Jdeveloper

Hi Experts,
I need to create a jar file for a J2SE project within Oracle9i Jdeveloper, making it possible execute the app. form a batch-file.
However when I try to execute the app from cmd I receive the following error:

java -jar PlotPrint.jar
Exception in thread main java.lang.NoClassDefFoundError: PlotPrintClient

Please help,
I have no Idea what is wrong

NB I'm using j2sdk1.4.2_13
Who is Participating?
Mayank SAssociate Director - Product EngineeringCommented:
>> responseData.elementAt(0)

Can you print the contents of the same:

System.out.println ( responseData.elementAt(0) ) ;

or System.out.println ( responseData.elementAt(0).getClass ().getName () ) ;

- that will tell what object is there - it is probably not an Element
Mayank SAssociate Director - Product EngineeringCommented:
>> java -jar PlotPrint.jar

I assume you are running it from the command prompt. You need to include the JAR file in the classpath. There are several ways, like either modifying the CLASSPATH environment variable or just specifying it to Java:

java -cp PlotPrint.jar -jar PlotPrint.jar

I 'think' that should work.
Mayank SAssociate Director - Product EngineeringCommented:
(You need to have the JAR file itself in the classpath, not the containing directory)
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

mhci_nneAuthor Commented:
Hi mayankeagle

Sorry that I took a while for replying, however now I know what the problem is, and I still need you help very much to fix it. The ploblem is that I'm specifing the main class incorrectly so please help me.

Here is my PlotPrint.Deploy file, what I need know is what to write in the element mainClass, then I think it should work.

<?xml version = '1.0' encoding = 'windows-1252'?>
<client-deployment xmlns="" nselem="client-deployment" class="oracle.jdeveloper.deploy.jar.ClientProfile">
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jdbc/lib/classes12.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jdbc/lib/nls_charset12.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jdev/lib/jdev-rt.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/soap/lib/soap.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/lib/xmlparserv2.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jlib/javax-ssl-1_2.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/jlib/jssl-1_2.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/j2ee/home/lib/activation.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/j2ee/home/lib/mail.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/j2ee/home/lib/http_client.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/webservices/lib/wsdl.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/lib/xmlparserv2.jar!/"/>
            <Item protocol="jar" path="file:/C:/Oracle9i_Jdev/jdevbin/lib/xmlcomp.jar!/"/>
   <defaultConnection class="java.lang.String"/>
   <earURL path="deploy/PlotPrint.ear"/>
   <jarURL path="deploy/PlotPrint.jar"/>
      <files class="[;"/>
mhci_nneAuthor Commented:
I have of couse tried with seveal different values in the element  mainClass, but without any luck. However I think it should work with writing this: <mainClass>PlotPrintClient</mainClass>

But it does not

PS the error i receive when writing java -jar PlotPrint.jar is the same as when I just double-click un the jar-file, so that is not the problem right ?
mhci_nneAuthor Commented:
Here is what how I created the executable jar file, from within Jdeveloper:

Deploying an Executable JAR File
You can make your simple archive or J2EE Client Module into an executable JAR file that you can launch with the java command.

To deploy an executable JAR file:
1) Select and right-click the simple archive or client icon in the Navigator to display the context menu.
2) Choose Properties.
3) Click JAR Options in the tree.
4) Select Include Manifest File (META-INF/MANIFEST.MF).
5) In the Main Class field, enter the fully qualified name of the application class that is to be invoked.
7) Click OK.
8) Launch the executable JAR file from the command line:
      java -jar myapp.jar        
      where myapp represents your JAR file name.
Like I said it's in 5) I'm doing something worng
Mayank SAssociate Director - Product EngineeringCommented:
>> PlotPrintClient

What is the package name of this class? You need to specify the full name of the class as packagename.PlotPrintClient in the main-class attribute.
mhci_nneAuthor Commented:
I have changed the element mainClass to

But now another probem has occured, since I get the following error when run the jar-file (When I run the app from within Jdev there are no warnings or errors).
@echo off
java -jar PlotPrint.jar
echo Test Plot and Print Batch-file!
---- out to cmd ----
Exception in thread "Thread-0" java.lang.ClassCastException:
        at Source)
Exception in thread "Thread-2" java.lang.ClassCastException:
        at Source)
Exception in thread "Thread-1" java.lang.ClassCastException:
        at Source)
Mayank SAssociate Director - Product EngineeringCommented:
>> at

Which line is that in your code? You are doing a wrong type-cast there
mhci_nneAuthor Commented:
sorry the package name is xxPlotPrint.MHCI so it should be ok right?
mhci_nneAuthor Commented:
I'm reading a SOAP xml doc using the following lib:

import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

Thus by including xmlparserv2.jar as a lib in the project then I can compile run etc within Jdev, but even though I included the xmlparserv2.jar and its sub libs in my executable jar-file I get this error.

I just have no idea why, and don't have a workaround :-(
Mayank SAssociate Director - Product EngineeringCommented:
That is fine - I need to know the code in that line 42
mhci_nneAuthor Commented:
It's the same problem in all three exceptions (the exactly the same code), however I was a bit to quick this is the line (the line before I process the xml doc :-)

import org.w3c.dom.Element;
responseData = new Vector();
responseData = test_NNE35_SOAP.getXSDdoc();
Element elements = ( (org.w3c.dom.Element)responseData.elementAt(0) ); (line 42)
mhci_nneAuthor Commented:
I have just tried executing the jar file from cmd
java -cp "xmlparserv2.jar jdev-rt.jar xmlcomp.jar" -jar XXNNE_I004.jar

xmlparserv2.jar, jdev-rt.jar and xmlcomp.jar were included in the directory (just for testing), but I stille get the same error :-(
mhci_nneAuthor Commented:
By the way I'm using these Oracle lib's:

Oracle XML Parser v2
Oracle SOAP
Oracle JDBC
mhci_nneAuthor Commented:
PLease help, someone must know what could cause the problem?
mhci_nneAuthor Commented:
Hi mayankeagle,

I solved my problem in another way, but thanks anyway
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.