GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes import statements and the files they import Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "import statements and the files they import" Watch "import statements and the files they import" New topic
Author

import statements and the files they import

Charles Knell
Greenhorn

Joined: Mar 19, 2006
Posts: 25
I was experimenting with using JDBC and XML with a reporting system I've developed that uses an Oracle database as the datasource.

Some time back I got everything working nicely on my computer and recently I needed to install the system on another computer. After hacking my way through a connection problem, I've come up against this error message on the new computer:

[java] Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xm
l/sql/query/OracleXMLQuery

where the next line calls out the class and method that I wrote in which the error is being thrown.

In my source code I import this class:

import oracle.xml.sql.query.*;

and on my machine there is no error. What has me stumped is, I don't point to the file containing the class with the classpath environment variable, or in any other way that I have been able to see, yet the program does not throw an error when I run it on my computer.

Now I can create a directory on the other computer in the same location and with the same name as the one on my computer, then copy the files there, and hope it will start working, but I still don't understand how Java, running on my computer, can find the .jar file when I don't point to it in some way.

Needless to say, I don't have a lot of confidence in copying the files to the new computer, so I'd like someone, please, to explain how Java "compiles" the imported class when I haven't told it where to find it.

Thanks.
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

Originally posted by Charles Knell:
In my source code I import this class:

import oracle.xml.sql.query.*;

and on my machine there is no error. What has me stumped is, I don't point to the file containing the class with the classpath environment variable, or in any other way that I have been able to see, yet the program does not throw an error when I run it on my computer.


So what does your CLASSPATH env variable have, on the computer where it works? Any chance that library has been installed as Extension?
[ September 18, 2007: Message edited by: Abhinav Srivastava ]
Charles Knell
Greenhorn

Joined: Mar 19, 2006
Posts: 25
Sorry to trouble you. I have found the solution. I have a <pathelement> nodes defined in my Ant build.xml file, and these point to the appropriate .jar files.

Thanks for your interest.
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
Originally posted by Charles Knell:
I was experimenting with using JDBC and XML with a reporting system I've developed that uses an Oracle database as the datasource.

Some time back I got everything working nicely on my computer and recently I needed to install the system on another computer. After hacking my way through a connection problem, I've come up against this error message on the new computer:

[java] Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xm
l/sql/query/OracleXMLQuery

where the next line calls out the class and method that I wrote in which the error is being thrown.

In my source code I import this class:

import oracle.xml.sql.query.*;

and on my machine there is no error. What has me stumped is, I don't point to the file containing the class with the classpath environment variable, or in any other way that I have been able to see, yet the program does not throw an error when I run it on my computer.

Now I can create a directory on the other computer in the same location and with the same name as the one on my computer, then copy the files there, and hope it will start working, but I still don't understand how Java, running on my computer, can find the .jar file when I don't point to it in some way.

Needless to say, I don't have a lot of confidence in copying the files to the new computer, so I'd like someone, please, to explain how Java "compiles" the imported class when I haven't told it where to find it.

Thanks.


not sure if i fully understand your issue, but here goes.

maybe the .jar file is in the ../bin directory? maybe the .jar file is in the same directory as a file(s) referencing it?
[ September 18, 2007: Message edited by: Michael Raymond Jr. ]

Scooby Snacks for everyone...<br /> <br />SCJA, SCJP 1.4
 
wood burning stoves
 
subject: import statements and the files they import