VisualBuilder
  Home > Java > Tutorials > Setting up the environment for XML and Java - Java XML Tutorial
Tell a friend
Link to us
Total Members
      Members: 84663
     
Sitemap Forum Chat
Home
Java XML Tutorial Home
1 . What is XML?
2 . HTML vs. XML
3 . XML Basics
4 . Why use XML in Java?
5 . Application areas of XML
6 . Standards
7 . Setting up the environment for XML and Java
8 . JAVA XML API
9 . Simple API for XML (SAX)
10 . Document Object Model (DOM)
11 . Basics of programming using DOM
12 . Should I use DOM or SAX? 
 
 
Java Home
Java Members (27610)
Java Member Articles ( 40 )
Java Discussion (273)
Java Q & A ( 153 )
- Java Ask Question
- Java Questions
- Java Unanswered Questions
Java Resources
Java Source Code (1095)
Java Articles (550)
Java Blogs (118)
Java Jobs (797)
Java Components (84)
Java Books (169)
Java Websites (126)
Java News (103)
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.Net Security,Internationalisation And Deployment
ASP.NET Tutorial
C# Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (451 )
Source Code (3275 )
Articles (359 )
Books (372 )
Components (1596 )
News (892 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise

Java xml Tutorial
 Setting up the environment for XML and Java
  << Prev: Standards Next: JAVA XML API >>

To use XML you will need a XML parser but before downloading a XML parser, you must make sure you have Java (JDK).


Setting up Java

Download JDK 1.3 from the following URL:


http://java.sun.com/j2se/1.3/

For Windows, the complete download is about 30 MB.

Run through the setup.

One of the main problems new Java developers have is setting the PATH and CLASSPATH.


For Windows 95/98/ME you edit the AUTOEXEC.BAT file with the new PATH and CLASSPATH settings and reboot your machine.


For Windows NT/2000 you edit the environment settings.

Both of these changes are described in the Java installation instructions.


Setting up XML


This tutorial will use the Xerces XML parser found on the Apache XML site.


1. Download the latest version of Xerces from the following URL:


http://xml.apache.org/dist/xerces-j/



If you are a Windows user, the following is the current download (at the time of writing - Xerces-J 1.4.0), you will need:


http://xml.apache.org/dist/xerces-j/Xerces-J-bin.1.4.3.zip


This tutorial assumes you copied the file to the c:\



2. Extract the contents of the zip and this will copy the files and create all the subdirectories. If you go to your Xerces-J 1.4.3 directory you should see xerces.jar and xercesSamples.jar


The next step is to edit the CLASSPATH in your AUTOEXEC.BAT file. You need to tell Java where it can find xerces.jar and xercesSamples.jar. Add the two files to your CLASSPATH. 



For example, 
set CLASSPATH=%CLASSPATH%; C:\Xerces-J-bin.1.4.3\xerces-1_4_3\ xerces.jar; C:\Xerces-J-bin.1.4.3\xerces-1_4_3\ xercesSamples.jar
 



In order to test your install, try one of the included samples, SAXCount.


Go to the directory of you have the two jar files, for example:


CD C:\Xerces-J-bin.1.4.3\xerces-1_4_3

(USEFUL TIP - in Windows 98/ME/2000 and NT you can drag and drop a directory into a command prompt window. This saves you from having to type in long directory names.)



Type the following to execute the SAXCount application: 


java sax.SAXCount data/personal.xml 



You should get the output of the application.

data/personal.xml: 280 ms (37 elems, 18 attrs, 140 spaces, 128 chars)

This is a breakdown of the personal.xml file in the data directory.


If you do not get this output then you are either in the wrong directory or most probably your CLASSPATH is incorrect. Check your AUTOEXEC.BAT file (Windows 95/98/ME) or your environment settings.


If this is all working, then you have correctly setup the environment for Java and XML.



Well Done



  << Prev: Standards Next: JAVA XML API >>
Java Xml Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
 
ADVERTISEMENT
Partner List
Code Project
ASP Alliance
More
 
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising