trying to find the real import files
-
Hello everybody. I am a newbie in Java and I am going to pose a question which may sound silly to most of you , but I run through the whole forum and article list without being able to find a hint. I have an error in my code which makes me think I do not have, in my classpath, the files needed for my "java.nio.*" import . Figuring my guess is right , how can I know , for any of the packages I import in my project, where the related files are ? And, which kind of files are they ? for instance , if I am importing the "java.net.*" or "the "java.io.*" packages, are they included in ".jar" files or not ? and where are the related containing files ? Is there a correspondence rule between the dotted import name form ( package.subpackage1.subpackage2....subpackageN.* ...) and a folder hierarchy somewhere in the filesystem ? I am using the Netbeans IDE, and I already checked the Tools|Library section, which includes a lot of .jar files, but only for a few of them I've been able to find the related .jar files. I read a lot of tutorials, manuals ,books and articles about the subject without finding a clear answer to these questions. Thank you
-
Hello everybody. I am a newbie in Java and I am going to pose a question which may sound silly to most of you , but I run through the whole forum and article list without being able to find a hint. I have an error in my code which makes me think I do not have, in my classpath, the files needed for my "java.nio.*" import . Figuring my guess is right , how can I know , for any of the packages I import in my project, where the related files are ? And, which kind of files are they ? for instance , if I am importing the "java.net.*" or "the "java.io.*" packages, are they included in ".jar" files or not ? and where are the related containing files ? Is there a correspondence rule between the dotted import name form ( package.subpackage1.subpackage2....subpackageN.* ...) and a folder hierarchy somewhere in the filesystem ? I am using the Netbeans IDE, and I already checked the Tools|Library section, which includes a lot of .jar files, but only for a few of them I've been able to find the related .jar files. I read a lot of tutorials, manuals ,books and articles about the subject without finding a clear answer to these questions. Thank you
tiwal wrote:
I have an error in my code which makes me think I do not have, in my classpath, the files needed for my "java.nio.*" import
What evidence do you have that leads to this conclusion? The nio package is part of the satndard runtime in rt.jar and should be installed as part of the Java installation.
Veni, vidi, abiit domum
-
tiwal wrote:
I have an error in my code which makes me think I do not have, in my classpath, the files needed for my "java.nio.*" import
What evidence do you have that leads to this conclusion? The nio package is part of the satndard runtime in rt.jar and should be installed as part of the Java installation.
Veni, vidi, abiit domum
In effect, actually no evidence at all, Richard, it's just a suspicion I made up by reading some documentation on the net. But if you say, as I originally thought, that "java.nio.*" is already in the standard runtime, that means my suspicion is wrong. Anyway, talking in general, is it possible to determine what is (and where is located) the .jar file where a particular import package in contained ?
-
In effect, actually no evidence at all, Richard, it's just a suspicion I made up by reading some documentation on the net. But if you say, as I originally thought, that "java.nio.*" is already in the standard runtime, that means my suspicion is wrong. Anyway, talking in general, is it possible to determine what is (and where is located) the .jar file where a particular import package in contained ?
tiwal wrote:
where a particular import package in contained ?
The majority are in the file rt.jar which is in the Java/jrex/lib directory. You can list all the individual jar files by going to that directory and running the command
jar tvf rt.jar
. As to your problem, it is much better to gather full diagnostic information rather than making guesses.Veni, vidi, abiit domum
-
tiwal wrote:
where a particular import package in contained ?
The majority are in the file rt.jar which is in the Java/jrex/lib directory. You can list all the individual jar files by going to that directory and running the command
jar tvf rt.jar
. As to your problem, it is much better to gather full diagnostic information rather than making guesses.Veni, vidi, abiit domum
-
Hello everybody. I am a newbie in Java and I am going to pose a question which may sound silly to most of you , but I run through the whole forum and article list without being able to find a hint. I have an error in my code which makes me think I do not have, in my classpath, the files needed for my "java.nio.*" import . Figuring my guess is right , how can I know , for any of the packages I import in my project, where the related files are ? And, which kind of files are they ? for instance , if I am importing the "java.net.*" or "the "java.io.*" packages, are they included in ".jar" files or not ? and where are the related containing files ? Is there a correspondence rule between the dotted import name form ( package.subpackage1.subpackage2....subpackageN.* ...) and a folder hierarchy somewhere in the filesystem ? I am using the Netbeans IDE, and I already checked the Tools|Library section, which includes a lot of .jar files, but only for a few of them I've been able to find the related .jar files. I read a lot of tutorials, manuals ,books and articles about the subject without finding a clear answer to these questions. Thank you
The direct answer to your question is yes, there is a direct correspondence between the dotted package names and the directory hierarchy. So for example, "java.nio.Buffer" is found in the directory "java/nio" and the file the loader looks for (in that directory) is called: "Buffer.class". What directory? you ask. The answer is any and all directories in the classpath are candidates (that includes jar files). A jar file is nothing more than a zip file with a different file extension. So open "rt.jar" in Winzip (or whatever zip file viewer you have lying around. In there you will see all the standard Java library directories, like "javax/swing/tree", "java/awt/font" etc. (these would correspond to packages javax.swing.tree.*, java.awt.font.*). And in the directory "java/nio" you should find all the java.nio files. EDIT: by the way, rt.jar is found in the jre/lib directory. So in Windows that would be "/Program Files/Java/jre/lib" or "/Program Files/Java/jdk/jre/lib"