Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2007-03-29
Medium Priority
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="http://xmlns.oracle.com/jdeveloper/903/deploy/j2ee-client-jar" 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="[Ljava.net.URL;"/>
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


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 xxPlotPrint.MHCI.NNE35_worker.run(NNE35_worker.java:42)
        at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-2" java.lang.ClassCastException:
        at xxPlotPrint.MHCI.OCEJobDB_worker.run(OCEJobDB_worker.java:41)
        at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-1" java.lang.ClassCastException:
        at xxPlotPrint.MHCI.NNE27_worker.run(NNE27_worker.java:42)
        at java.lang.Thread.run(Unknown Source)
LVL 30

Expert Comment

by:Mayank S
ID: 18832368
>> at xxPlotPrint.MHCI.NNE35_worker.run(NNE35_worker.java:42)

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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

604 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