You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Swanson, Brion" <Br...@westgroup.com> on 2001/03/05 15:55:59 UTC

RE: Problem with Xerces-1_2_1(Java)

If you want to use org.apache.xerces.parsers.SAXParser, you should import it
as you did with org.xml.sax.XMLReader. Alternatively you can just call: 
    XMLReader parser = new org.apache.xerces.parsers.SAXParser ();
 
As for your second problem, make sure you remove the 'package sax;' line or
change it to reflect the new directory in which you placed your copy. (i.e.
'package practice;')
 
Brion Swanson
 

-----Original Message-----
From: Rajarshi Ghosh [mailto:ghoshraja@yahoo.com]
Sent: Monday, February 05, 2001 12:01 AM
To: xerces-j-user@xml.apache.org
Cc: xerces-c-dev@xml.apache.org
Subject: Problem with Xerces-1_2_1(Java)


Hi ,
I have downloaded the xerces-1_2_1 from apache site.I am reading the
Java-Xml Book from Oreilly.
After extracting the xerces files I have set the classpath to
<roo>/xerces.jar and <root>xercesSamples.jar.
Then I have created one folder called 'practice' inside 'Samples' i.e 
(<root>/Xerces/Samples/practice).Now I am facing two problems.
 1. I wrote SAXPerserDemo.java and saved it inside 'practice' as below:
  
import org.xml.sax.XMLReader;
 
public class SAXPerserDemo{
 public void performDemo(String uri){
  System.out.println("Parsing XML FIle :"+uri+"\n\n");
  try{
   XMLReader parser =
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(
);
  }catch(Exception e){
   e.printStackTrace();
  }
 }
 
 public static void main(String args[]){
  if(args.length == 0){
   System.out.println("Usage:java SAXPerserDemo [XML URI]");
   System.exit(0);
  }
  String uri = args[0];
  SAXPerserDemo perserDemo = new SAXPerserDemo();
  perserDemo.performDemo(uri);
 }
 
}
 In oreilly it is given :
 XMLReader parser = new SAXParser();
 But this line does not compile in this version of Xerces.So I made the
changes as
XMLReader parser =
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(
);
then it compiles successfully.
Now what should I do to get the line XMLReader parser = new SAXParser();
compiled successfully.
 
 2. When I copiled the file SAX2Count.java from 'sax' to 'practice'
    directory and made some changes and rename it as SAX2CountModified.java
then it compiled
    successfully but when I gave the command java SAX2CountModified then it
gave me the exception 
    as:
 G:\Xerces\Samples\practice>java SAX2CountModified
Exception in thread "main" java.lang.NoClassDefFoundError: SAX2CountModified
(wr
ong name: sax/SAX2CountModified)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:403)
        at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10
1)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
        at java.net.URLClassLoader.access$1(URLClassLoader.java:216)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:280)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:237)
 
*** Please inform me what should I do to get it run.
 Waiting for your mail.
  
 With Regards
  Rajarshi Ghosh
( ghoshraja@yahoo.com <ma...@yahoo.com> )


Re: Problem with Xerces-1_2_1(Java)

Posted by Rajarshi Ghosh <gh...@yahoo.com>.
Dear Brion Swanson,
   Thanks for the solution.
Regarding the second problem you wrote" make sure you remove the 'package
sax;' line or
change it to reflect the new directory in which you placed your copy.
(i.e.'package practice;')."
Please tell me where I have to change (or get the line)
'package sax' to 'package.practice'.
Waiting for your mail.
Thanks in advance.
Regards
Rajarshi Ghosh




----- Original Message -----
From: "Swanson, Brion" <Br...@westgroup.com>
To: <xe...@xml.apache.org>
Sent: Monday, March 05, 2001 8:25 PM
Subject: RE: Problem with Xerces-1_2_1(Java)


> If you want to use org.apache.xerces.parsers.SAXParser, you should import
it
> as you did with org.xml.sax.XMLReader. Alternatively you can just call:
>     XMLReader parser = new org.apache.xerces.parsers.SAXParser ();
>
> As for your second problem, make sure you remove the 'package sax;' line
or
> change it to reflect the new directory in which you placed your copy.
(i.e.
> 'package practice;')
>
> Brion Swanson
>
>
> -----Original Message-----
> From: Rajarshi Ghosh [mailto:ghoshraja@yahoo.com]
> Sent: Monday, February 05, 2001 12:01 AM
> To: xerces-j-user@xml.apache.org
> Cc: xerces-c-dev@xml.apache.org
> Subject: Problem with Xerces-1_2_1(Java)
>
>
> Hi ,
> I have downloaded the xerces-1_2_1 from apache site.I am reading the
> Java-Xml Book from Oreilly.
> After extracting the xerces files I have set the classpath to
> <roo>/xerces.jar and <root>xercesSamples.jar.
> Then I have created one folder called 'practice' inside 'Samples' i.e
> (<root>/Xerces/Samples/practice).Now I am facing two problems.
>  1. I wrote SAXPerserDemo.java and saved it inside 'practice' as below:
>
> import org.xml.sax.XMLReader;
>
> public class SAXPerserDemo{
>  public void performDemo(String uri){
>   System.out.println("Parsing XML FIle :"+uri+"\n\n");
>   try{
>    XMLReader parser =
>
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(
> );
>   }catch(Exception e){
>    e.printStackTrace();
>   }
>  }
>
>  public static void main(String args[]){
>   if(args.length == 0){
>    System.out.println("Usage:java SAXPerserDemo [XML URI]");
>    System.exit(0);
>   }
>   String uri = args[0];
>   SAXPerserDemo perserDemo = new SAXPerserDemo();
>   perserDemo.performDemo(uri);
>  }
>
> }
>  In oreilly it is given :
>  XMLReader parser = new SAXParser();
>  But this line does not compile in this version of Xerces.So I made the
> changes as
> XMLReader parser =
>
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(
> );
> then it compiles successfully.
> Now what should I do to get the line XMLReader parser = new SAXParser();
> compiled successfully.
>
>  2. When I copiled the file SAX2Count.java from 'sax' to 'practice'
>     directory and made some changes and rename it as
SAX2CountModified.java
> then it compiled
>     successfully but when I gave the command java SAX2CountModified then
it
> gave me the exception
>     as:
>  G:\Xerces\Samples\practice>java SAX2CountModified
> Exception in thread "main" java.lang.NoClassDefFoundError:
SAX2CountModified
> (wr
> ong name: sax/SAX2CountModified)
>         at java.lang.ClassLoader.defineClass0(Native Method)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:403)
>         at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10
> 1)
>         at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
>         at java.net.URLClassLoader.access$1(URLClassLoader.java:216)
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:280)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:237)
>
> *** Please inform me what should I do to get it run.
>  Waiting for your mail.
>
>  With Regards
>   Rajarshi Ghosh
> ( ghoshraja@yahoo.com <ma...@yahoo.com> )
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Re: Problem with Xerces-1_2_1(Java)

Posted by Rajarshi Ghosh <gh...@yahoo.com>.
Dear Biron,
 Many thanks for the solution.I got both the problem solved following your
suggestions.
Regards
Rajarshi Ghosh

----- Original Message -----
From: "Swanson, Brion" <Br...@westgroup.com>
To: <xe...@xml.apache.org>
Sent: Monday, March 05, 2001 8:25 PM
Subject: RE: Problem with Xerces-1_2_1(Java)


> If you want to use org.apache.xerces.parsers.SAXParser, you should import
it
> as you did with org.xml.sax.XMLReader. Alternatively you can just call:
>     XMLReader parser = new org.apache.xerces.parsers.SAXParser ();
>
> As for your second problem, make sure you remove the 'package sax;' line
or
> change it to reflect the new directory in which you placed your copy.
(i.e.
> 'package practice;')
>
> Brion Swanson
>
>
> -----Original Message-----
> From: Rajarshi Ghosh [mailto:ghoshraja@yahoo.com]
> Sent: Monday, February 05, 2001 12:01 AM
> To: xerces-j-user@xml.apache.org
> Cc: xerces-c-dev@xml.apache.org
> Subject: Problem with Xerces-1_2_1(Java)
>
>
> Hi ,
> I have downloaded the xerces-1_2_1 from apache site.I am reading the
> Java-Xml Book from Oreilly.
> After extracting the xerces files I have set the classpath to
> <roo>/xerces.jar and <root>xercesSamples.jar.
> Then I have created one folder called 'practice' inside 'Samples' i.e
> (<root>/Xerces/Samples/practice).Now I am facing two problems.
>  1. I wrote SAXPerserDemo.java and saved it inside 'practice' as below:
>
> import org.xml.sax.XMLReader;
>
> public class SAXPerserDemo{
>  public void performDemo(String uri){
>   System.out.println("Parsing XML FIle :"+uri+"\n\n");
>   try{
>    XMLReader parser =
>
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(
> );
>   }catch(Exception e){
>    e.printStackTrace();
>   }
>  }
>
>  public static void main(String args[]){
>   if(args.length == 0){
>    System.out.println("Usage:java SAXPerserDemo [XML URI]");
>    System.exit(0);
>   }
>   String uri = args[0];
>   SAXPerserDemo perserDemo = new SAXPerserDemo();
>   perserDemo.performDemo(uri);
>  }
>
> }
>  In oreilly it is given :
>  XMLReader parser = new SAXParser();
>  But this line does not compile in this version of Xerces.So I made the
> changes as
> XMLReader parser =
>
(XMLReader)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance(
> );
> then it compiles successfully.
> Now what should I do to get the line XMLReader parser = new SAXParser();
> compiled successfully.
>
>  2. When I copiled the file SAX2Count.java from 'sax' to 'practice'
>     directory and made some changes and rename it as
SAX2CountModified.java
> then it compiled
>     successfully but when I gave the command java SAX2CountModified then
it
> gave me the exception
>     as:
>  G:\Xerces\Samples\practice>java SAX2CountModified
> Exception in thread "main" java.lang.NoClassDefFoundError:
SAX2CountModified
> (wr
> ong name: sax/SAX2CountModified)
>         at java.lang.ClassLoader.defineClass0(Native Method)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:403)
>         at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10
> 1)
>         at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
>         at java.net.URLClassLoader.access$1(URLClassLoader.java:216)
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:280)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:275)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:237)
>
> *** Please inform me what should I do to get it run.
>  Waiting for your mail.
>
>  With Regards
>   Rajarshi Ghosh
> ( ghoshraja@yahoo.com <ma...@yahoo.com> )
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com