Solved

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

Posted on 2007-03-29
17
633 Views
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
0
Comment
Question by:mhci_nne
  • 11
  • 6
17 Comments
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> 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.

http://www.mindprod.com/jgloss/classpath.html
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
(You need to have the JAR file itself in the classpath, not the containing directory)
0
 

Author Comment

by:mhci_nne
Comment Utility
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">
   <archiveOptions>
      <additionalManifests/>
      <compressed>false</compressed>
      <hasManifest>true</hasManifest>
      <mainClass>classes/xxPlotPrint/MHCI/PlotPrintClient.class</mainClass>
   </archiveOptions>
   <archiveTargetPlatform/>
   <cdaSettings>
      <additionalArchives/>
      <afterFilters/>
      <beforeFilters/>
      <duringFilters/>
      <selectedArchives>
         <archives>
            <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!/"/>
         </archives>
         <selectionMode>0</selectionMode>
      </selectedArchives>
   </cdaSettings>
   <defaultConnection class="java.lang.String"/>
   <deployClientMaxHeapSize/>
   <earURL path="deploy/PlotPrint.ear"/>
   <enterpriseAppName/>
   <jarURL path="deploy/PlotPrint.jar"/>
   <profileDeps/>
   <properties/>
   <selectedProjectFiles>
      <autoInclude>true</autoInclude>
      <deploySourceAs>0</deploySourceAs>
      <files class="[Ljava.net.URL;"/>
      <selectionFilters/>
   </selectedProjectFiles>
</client-deployment>
0
 

Author Comment

by:mhci_nne
Comment Utility
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 ?
0
 

Author Comment

by:mhci_nne
Comment Utility
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
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> 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.
0
 

Author Comment

by:mhci_nne
Comment Utility
I have changed the element mainClass to
<mainClass>xxPlotPrint.MHCI.PlotPrintClient</mainClass>

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).
 
----Batch-file-----
@echo off
java -jar PlotPrint.jar
echo Test Plot and Print Batch-file!
pause
---- out to cmd ----
Exception in thread "Thread-0" java.lang.ClassCastException:
      com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
        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:
      com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
        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:
      com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl
        at xxPlotPrint.MHCI.NNE27_worker.run(NNE27_worker.java:42)
        at java.lang.Thread.run(Unknown Source)
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
>> 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
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:mhci_nne
Comment Utility
sorry the package name is xxPlotPrint.MHCI so it should be ok right?
0
 

Author Comment

by:mhci_nne
Comment Utility
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 :-(
0
 
LVL 30

Expert Comment

by:mayankeagle
Comment Utility
That is fine - I need to know the code in that line 42
0
 

Author Comment

by:mhci_nne
Comment Utility
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)
0
 

Author Comment

by:mhci_nne
Comment Utility
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 :-(
0
 

Author Comment

by:mhci_nne
Comment Utility
By the way I'm using these Oracle lib's:

Oracle XML Parser v2
Oracle SOAP
Oracle JDBC
0
 

Author Comment

by:mhci_nne
Comment Utility
PLease help, someone must know what could cause the problem?
0
 
LVL 30

Accepted Solution

by:
mayankeagle earned 500 total points
Comment Utility
>> 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
0
 

Author Comment

by:mhci_nne
Comment Utility
Hi mayankeagle,

I solved my problem in another way, but thanks anyway
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now