BizTalk Utilities CV ,   Jobs ,   Code library  
 
 
Page 2 of 13

 

Previous Page Table Of Contents Next Page

Java and the XML DOM, cont.

Getting XML for Java

The first step is to download XML for Java at www.alphaworks.ibm.com/tech/ xml4j. Currently, you only need to navigate to that site, click the Download button, then select a file to download, and click the Download Selected File button. For example, if you're on a UNIX system, you can select the file labeled Binary distribution packaged as a UNIX Tar.gz file, which is XML4J-bin.3.0.1.tar.gz as of this writing. If you're on Windows, you can select the file labeled Binary distribution packaged as a Windows ZIP file, which is XML4J-bin.3.0.1.zip as of this writing. You can also download the XML for Java source code, which means that you can build everything for yourself.

After you've downloaded the compressed XML for Java file, you must uncompress it yourself (in Windows, make sure that you use an unzip utility that can handle long filenames). That's all for actually installing XML for Java-now you must make sure that Java can find it.

Setting CLASSPATH

As far as we're concerned, XML for Java is a huge set of classes ready for us to use. Those classes are stored in Java JAR (Java Archive) files, and we must make sure that Java can search those JAR files for the classes that it needs.

I discussed this process a little in the last chapter when I mentioned using the Java CLASSPATH environment variable. This is the variable that you set to tell Java where to look for additional classes your code may require. In our case, the JAR files we'll need to search for classes are called xerces.jar and xercesSamples.jar (these names may have changed by the time you read this).

Unfortunately, the way you set the CLASSPATH variable can vary by system. For example, to permanently set the class path in Windows NT, you use the Control Panel. In the System Properties dialog box, you click the Environment tab, then click the CLASSPATH variable, and enter the new value there. In Windows 95 or 98, you can use the MS-DOS SET command in autoexec.bat, which sets the value of environment variables. Note, however, that you can also use the MS-DOS SET command to set the class path in Windows 95, 98, and NT to set the class path until the MS-DOS window is closed, which is perhaps the easiest way. For example, if xerces.jar and xercesSamples.jar are in the directory C:\xmlparser\XML4J_3_0_1 on your system, you could use a SET command like this (and put it all on one line):

C:\>SET CLASSPATH=%CLASSPATH%;C:\xmlparser\XML4J_3_0_1\xerces.jar;

C:\xmlparser\XML4J_3_0_1\xercesSamples.jar

Take a look at the Java documentation to see how to set CLASSPATH on your system. There's a shortcut if you can't get the CLASSPATH variable working; you can use the -classpath switch when working with the javac and java tools. For example, here's how I compile and run a program named browser.java using that switch to specify the class path I want to use (both commands should be on one line):

%javac -classpath C:\xmlparser\XML4J_3_0_1\xerces.jar;

C:\xmlparser\XML4J_3_0_1\xercesSamples.jar browser.java

%java -classpath C:\xmlparser\XML4J_3_0_1\xerces.jar;

C:\xmlparser\XML4J_3_0_1\xercesSamples.jar browser

We're ready to start working with code. I'll start by writing an example that parses an XML document.

 

Page 2 of 13

 

Previous Page Table Of Contents Next Page
 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)




Chicago Web Site Design
fax online
internet fax
D&g sunglasses
air freshener
odor remover


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP