• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

import in Windows environment

 
Les Hayden
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to play with the Java XML APIs and I'm having trouble getting the import to work.
I've entered the following:
import org.w3c.dom.*;
public class XMLTest {
private Document document;

/** Creates a new instance of ReplaceText */
public XMLTest() {
}
public static void main(String[] args) {
}

}
and get the following error:
ReplaceText.java [1:1] package org.w3c.dom does not exist
import org.w3c.dom.*;
^
I have placed a reference to the location of the dom.jar file on my class path which according to the install instructions is all I have to do.
I'm obviously missing something basic here
Les
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Les,
Why don't you show us how your CLASSPATH is set and maybe we can determine the problem. You can also put the jar file in the extension directory of the JRE. That path is <SDK_Directory>\jre\lib\ext\ where <SDK_Directory> is the directory where the Java SDK is installed. For example on my machine it is C:\j2sdk1.4.1\jre\lib\ext\.
Michael Morris
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that directory is only supposed to be used by official Java extensions from Sun. Figuring out how the whole classpath thing works isn't a huge ordeal, but once you figure it out life is easy.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, how are you compiling? From the command line with javac or through an IDE?
 
Les Hayden
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for looking at this.
The path on my computer is:

(edited using the little paper and pen icon - you too can do this to your own posts)
[ March 21, 2003: Message edited by: Cindy Glass ]
 
Les Hayden
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And that is the CLASSPATH, not the PATH.
Thanks again.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les,
Please edit your post to break apart that big long line in the code tag.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
Also, how are you compiling? From the command line with javac or through an IDE?
 
Les Hayden
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry,
I put the relavent files on separate lines.
.;C:\SQLLIB\java\db2java.zip;C:\SQLLIB\java\runtime.zip;C:\SQLLIB\bin;
C:\jaxp\dom.jar;
c:\jaxp\jaxp-api.jar;
c:\jaxp\sax.jar;
c:\jaxp\xalan.jar;
c:\jaxp\xercesImpl.jar;
c:\jaxp\xsltc.jar;
C:\Program Files\Altova\xmlspy\XMLSpyInterface.jar
I'm using Forte(Sun One Studio).
Thanks again for your time.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with Forte, it might do something obnoxious like ignore your system CLASSPATH setting and just use its own. What happens when you try to compile the same code from the command line with javac? If it works, then it's a Forte issue and I'd recommend moseying on over to the IDEs forum.
And of course, I'd double check that the dom.jar file is where the CLASSPATH says it is and that it does indeed contain the org.w3c.dom package.
So, how do things turn out?
 
Les Hayden
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The odd thuding sound you hear is my head being drummed against the wall. Indeed, javac happily compiles the program.
I should have thought of that myself.
I know better, really I do :roll:
Under the subject of RTFD:
The Class Path property editor sets the path to the sources that the IDE uses. By default the IDE uses its internal class path, which includes all mounted filesystems and various directories in the IDE's installation and user directories . The IDE ignores your CLASSPATH environment variable. You can set the specific class path that the IDE uses with the Class Path property editor. This setting overrides the IDE's internal class path.
[ March 24, 2003: Message edited by: Les Hayden ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic