[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

which .jar files?

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
benpung
Asked:
benpung
  • 16
  • 12
1 Solution
 
CEHJCommented:
None if you have Java 1.4
0
 
benpungAuthor Commented:
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
 
CEHJCommented:
>>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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
benpungAuthor Commented:
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
 
CEHJCommented:
What version of Java have you got on your Unix server?
0
 
benpungAuthor Commented:
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
 
CEHJCommented:
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
 
benpungAuthor Commented:
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
 
benpungAuthor Commented:
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
 
benpungAuthor Commented:
whoops, sorry about that last post. hit refresh :-)
0
 
JituCommented:
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
 
benpungAuthor Commented:
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
 
CEHJCommented:
Upgrade it ;-)
0
 
benpungAuthor Commented:
i have to install jdk 1.4 directly in the database right?
0
 
CEHJCommented:
No. JRE on the server. JDK only necessary if you're developing *at* the server.
0
 
benpungAuthor Commented:
can you tell me the difference between jre and jdk? i'm a little confused there.
0
 
CEHJCommented:
JRE for running Java. JDK for developing AND running.
0
 
benpungAuthor Commented:
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
 
benpungAuthor Commented:
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
 
CEHJCommented:
I've already said

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

and

>>JDK for developing AND running.
0
 
benpungAuthor Commented:
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
 
CEHJCommented:
>>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
 
benpungAuthor Commented:
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
 
CEHJCommented:
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
 
benpungAuthor Commented:
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
 
CEHJCommented:
>>i'm hoping the dba has more knowledge of this part than i do

i wouldn't bet on it ;-)
0
 
benpungAuthor Commented:
he's pretty good. i'll give him a crack at it and let you know if we have any more questions. thanks.
0
 
benpungAuthor Commented:
ok, got the java working with oracle. thanks for your help.
0
 
CEHJCommented:
OK :-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

  • 16
  • 12
Tackle projects and never again get stuck behind a technical roadblock.
Join Now