?
Solved

which .jar files?

Posted on 2003-03-24
29
Medium Priority
?
223 Views
Last Modified: 2013-11-23
can someone tell me which .jar files i will need loaded to run this code? thanks.

ben

********************************code******************************

import java.io.*;
import java.lang.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

/**
 * A simple demo of JAXP 1.1
 */
public class TransformXml {

    /**
     * Accept three command line arguments: the name of an XML
     * file, the name of an XSLT stylesheet, and the output file.
     * The result of the transformation is written to the output file.
     */

    public static void main (String[] args)
         throws javax.xml.transform.TransformerException {
     if (args.length != 3) {
       System.err.println("Usage:");
       System.err.println("  java " + TransformXml.class.getName(  )
                 + " xmlFileName xsltFileName outputFileName");
       System.exit(1);
     }

     File xmlFile = new File(args[0]);
     File xsltFile = new File(args[1]);
     File outputFile = new File (args[2]);

     javax.xml.transform.Source xmlSource =
       new javax.xml.transform.stream.StreamSource(xmlFile);
     javax.xml.transform.Source xsltSource =
       new javax.xml.transform.stream.StreamSource(xsltFile);
     javax.xml.transform.Result result =
       new javax.xml.transform.stream.StreamResult(outputFile);

     // create an instance of TransformerFactory
     javax.xml.transform.TransformerFactory transFact =
       javax.xml.transform.TransformerFactory.newInstance();

     javax.xml.transform.Transformer trans =
        transFact.newTransformer(xsltSource);

     trans.transform(xmlSource, result);

 }
}
0
Comment
Question by:benpung
[X]
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
  • 16
  • 12
29 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 8197420
None if you have Java 1.4
0
 
LVL 1

Author Comment

by:benpung
ID: 8197570
maybe i should explain myself better.  i am running windows 2k pro. i downloaded the sdk 1.4.1 and the jaxp from java.sun.com.  i can complile and run the above code on my local machine. i am doing some development in an oracle 8.1.7 database running on a unix server. i want to be able to compile and run the above java code within the database. however, i can't compile the code in the database. i get this error:

The following error has occurred:

JAVA SOURCE EMS_PROCS.TRANSFORMXML
On line:  0
TRANSFORMXML:18: Class javax.xml.transform.TransformerException not found in throws.

i was thinking that this means that it can't find the javax.xml.transform class b/c if i move this line, it complains about the next line that has "javax.xml.transform" in it. so, i'm trying to find out what classes i need to tell the dba to load in to oracle. any ideas?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8197605
>>i downloaded the sdk 1.4.1 and the jaxp from java.sun.com

I'd beware of installing both - you may get conflicts. Try removing the jaxp from your classpath/ext directory
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:benpung
ID: 8197632
i'm not having any problems on my machine. it works great on my box. the problem is that the dba's don't want to install the entire packages when i probably only need a couple of .jar files added to the database. i'm trying to find out which files in need added....
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8197667
What version of Java have you got on your Unix server?
0
 
LVL 1

Author Comment

by:benpung
ID: 8197699
i'm not sure. is that something i should have them check? if so, what version do i want? you said 1.4 or higher? do i even need any of the jaxp?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8197753
If you just want to run your Java there, just install JRE 1.4 and your xml should work fine.
http://java.sun.com/getjava
0
 
LVL 1

Author Comment

by:benpung
ID: 8197807
i don't know much about the dba functions in oracle, but from what they are telling me they have to run sql scripts to build the engine for oracle to use. i will tell them this and let you know if it works out. thanks for your help.
0
 
LVL 1

Author Comment

by:benpung
ID: 8197907
i'm not having any problems on my machine. it works great on my box. the problem is that the dba's don't want to install the entire packages when i probably only need a couple of .jar files added to the database. i'm trying to find out which files in need added....
0
 
LVL 1

Author Comment

by:benpung
ID: 8197915
whoops, sorry about that last post. hit refresh :-)
0
 
LVL 1

Expert Comment

by:Jitu
ID: 8201380
CEHJ is right.
Just have JDK1.4 or JRE for 1.4 will ensure that your program runs fine. All the XML related packages u need have been made part of JDK 1.4 now.
0
 
LVL 1

Author Comment

by:benpung
ID: 8202228
what if i have a less recent version of java? say 1.3? are there .jar files i can get from the 1.4 version that will allow me to do this? i'm not sure of the version yet, i'm just doing the "what if" thing. thanks for your help.

ben
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8202245
Upgrade it ;-)
0
 
LVL 1

Author Comment

by:benpung
ID: 8205721
i have to install jdk 1.4 directly in the database right?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8205794
No. JRE on the server. JDK only necessary if you're developing *at* the server.
0
 
LVL 1

Author Comment

by:benpung
ID: 8209712
can you tell me the difference between jre and jdk? i'm a little confused there.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8209726
JRE for running Java. JDK for developing AND running.
0
 
LVL 1

Author Comment

by:benpung
ID: 8209797
ahhhh (light bulb on). ok. i'll lean on my server guys and see if they will get this loaded for me and let you know. thanks.
0
 
LVL 1

Author Comment

by:benpung
ID: 8209811
so if i only load the jre, i will still be able to compile the code inside the database right? or do i need the sdk in order to compile and the jre allows only execution?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8209824
I've already said

>>JDK only necessary if you're developing *at* the server.

and

>>JDK for developing AND running.
0
 
LVL 1

Author Comment

by:benpung
ID: 8209831
ok, i think i found my own answer. the jre contains no compilers correct? so if i want to be able to paste my java code into sqlplus, and issue the command:

alter java source <mycode> compile;

i won't be able to do that with the jre correct? i'm thinking i actually want the sdk. thoughts?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8209864
>>the jre contains no compilers correct?

Correct. As i've said several times, JRE is for running, JDK is for running AND developing

>>alter java source <mycode> compile;

Can you do that in SQLPlus?!!
0
 
LVL 1

Author Comment

by:benpung
ID: 8210297
yes, you can create java code from sql plus (oracle 8i or higher). the trick is you have to create a pl/sql "wrapper" to go around it. for example, here is some java code i currently have running in the database to allow me to issue operating system commands from inside a pl/sql program:

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED HOST AS
import java.lang.*;
import java.io.*;

public class Host
{
  public static void executeCommand (String command, String etype) throws IOException
  {
    String[] wFullCommand = {"C:\\winnt\\system32\\cmd.exe", "/y", "/c", command};
    String[] uFullCommand = {"/bin/sh", "-c", command};
    if (etype.toUpperCase().equals("W"))
      Runtime.getRuntime().exec(wFullCommand);
    else if(etype.toUpperCase().equals("U+"))
      Runtime.getRuntime().exec(uFullCommand);
    else if(etype.toUpperCase().equals("U"))
      Runtime.getRuntime().exec(command);
  }
};
/

And here is the pl/sql "wrapper", which is just a pl/sql procedure that invokes the java code and passes it parameters.

CREATE OR REPLACE PROCEDURE Host_Command_Proc (p_command  IN  VARCHAR2, p_etype  IN  VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String, java.lang.String)';
/

so to compile the java in the database, i just paste in the java procedure and hit enter. that loads the code into the database. then i have to compile using the command:
alter java source Host compile;
the java is then compiled in the database. then i slap in my wrapper procedure, and i can call the java through it. for example, i can combine 2 files on the unix server from within a pl/sql program by calling the host_command_proc procedure as follows:

host_command_proc ('cat /my/dir/path/file1 /my/dir/path/file2 > /my/dir/path/file3','U+');

this will execute the java code with the two parameters (one being the command, the other the o.s. flag).

this is exaclty what i am trying to do with the code i originially asked about. i want to be able to pass that original code the xmlfile, xslfile, and output file from within a pl/sql procedure, and have it do it's thing. but i'm getting errors when i try to compile in sqlplus b/c i don't have the right classes loaded.

ben
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 80 total points
ID: 8210395
Check the Oracle docs about how to set the Java environment. You need to install the 1.4 JDK and point Oracle to it.
0
 
LVL 1

Author Comment

by:benpung
ID: 8210653
yeah, i figured that. i'm hoping the dba has more knowledge of this part than i do. i just wanted to be able to tell him for sure what i needed loaded. i'm hoping he knows how to do the setup in oracle as far as the pointing. when he gets back here after lunch i'll have him banging his head on his desk :-) thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8210720
>>i'm hoping the dba has more knowledge of this part than i do

i wouldn't bet on it ;-)
0
 
LVL 1

Author Comment

by:benpung
ID: 8212254
he's pretty good. i'll give him a crack at it and let you know if we have any more questions. thanks.
0
 
LVL 1

Author Comment

by:benpung
ID: 8237806
ok, got the java working with oracle. thanks for your help.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8238113
OK :-)
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
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 …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 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