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

Posted on 2007-03-29
Last Modified: 2013-12-29
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
Question by:mhci_nne
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 6
LVL 30

Expert Comment

by:Mayank S
ID: 18818623
>> 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.
LVL 30

Expert Comment

by:Mayank S
ID: 18818629
(You need to have the JAR file itself in the classpath, not the containing directory)

Author Comment

ID: 18831641
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="[;"/>
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.


Author Comment

ID: 18831674
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 ?

Author Comment

ID: 18831768
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
LVL 30

Expert Comment

by:Mayank S
ID: 18832344
>> 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.

Author Comment

ID: 18832361
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)
LVL 30

Expert Comment

by:Mayank S
ID: 18832368
>> at

Which line is that in your code? You are doing a wrong type-cast there

Author Comment

ID: 18832594
sorry the package name is xxPlotPrint.MHCI so it should be ok right?

Author Comment

ID: 18832619
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 :-(
LVL 30

Expert Comment

by:Mayank S
ID: 18832628
That is fine - I need to know the code in that line 42

Author Comment

ID: 18832643
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)

Author Comment

ID: 18834972
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 :-(

Author Comment

ID: 18834994
By the way I'm using these Oracle lib's:

Oracle XML Parser v2
Oracle SOAP
Oracle JDBC

Author Comment

ID: 18848981
PLease help, someone must know what could cause the problem?
LVL 30

Accepted Solution

Mayank S earned 500 total points
ID: 19012717
>> 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

Author Comment

ID: 19014143
Hi mayankeagle,

I solved my problem in another way, but thanks anyway

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question