Code Comments
Programming Forum and web based access to our favorite programming groups.there's something about java's API that baffles me... when I put code like this at the beginning of my programs.. import java.io.*; import java.util.*; import java.text.*; my programs (stand-alone's I compile & run in DOS shell) are located in my hard drive.. so how does java find these classes? they're not in my hard drive (I have searched for them, I have SDK and all that installed, but that does't include all these classes..) classes are up on java.sun, right???? I find this baffling.. am I missing something here? (probably..) thank you.. Frances
Post Follow-up to this message"Frances Del Rio" <fdr58@yahoo.com> wrote in message news:2rb61mF17b510U1@uni-berlin.de... > > there's something about java's API that baffles me... when I put code > like this at the beginning of my programs.. > > import java.io.*; > import java.util.*; > import java.text.*; > > my programs (stand-alone's I compile & run in DOS shell) are located in > my hard drive.. so how does java find these classes? they're not in my > hard drive (I have searched for them, I have SDK and all that installed, > but that does't include all these classes..) classes are up on java.sun, > right???? I find this baffling.. am I missing something here? > (probably..) thank you.. Frances Now try and search for the file rt.jar found it? that is where the classes are. -- Mike W
Post Follow-up to this messageok, I see.. so what are .jar files, exactly?? they contain classes, right?? in my HD icon assoc'd w/them makes them look like a text file (is it ok for to open them so I can look?) it is FULL of .jar files in there, not just rt.jar.. what are all the others? (also tons of .idx and .zip files.. have no idea what those contain.. see screen-shot at http://www.francesdelrio.com/java/jar.gif..) talk to me about this stuff, pls.. thank you very much for yr response.. Frances Frances Del Rio wrote: > > there's something about java's API that baffles me... when I put code > like this at the beginning of my programs.. > > import java.io.*; > import java.util.*; > import java.text.*; > > my programs (stand-alone's I compile & run in DOS shell) are located in > my hard drive.. so how does java find these classes? they're not in my > hard drive (I have searched for them, I have SDK and all that installed, > but that does't include all these classes..) classes are up on java.sun, > right???? I find this baffling.. am I missing something here? > (probably..) thank you.. Frances > > >
Post Follow-up to this messageIn article <2rb61mF17b510U1@uni-berlin.de>, fdr58@yahoo.com enlightened us with... > > there's something about java's API that baffles me... when I put code > like this at the beginning of my programs.. > > import java.io.*; > import java.util.*; > import java.text.*; > > my programs (stand-alone's I compile & run in DOS shell) are located in > my hard drive.. so how does java find these classes? they're not in my > hard drive (I have searched for them, I have SDK and all that installed, > but that does't include all these classes..) classes are up on java.sun, > right???? I find this baffling.. am I missing something here? > (probably..) thank you.. Frances > The classes are part of the standard JVM (Java Virtual Machine) that users get when they install Java. If a user doesn't have Java, your program won't run. As to the location of the classes, since they are standard with an intall, the compiler already knows where to look. For non-standard classes, the compiler would look at your CLASSPATH, which i s an environmental variable that can be set via OS commands or, for Windows, i n your startup .bat file (I think it's autoconfig.bat or something). In Unix, you can set it in your .profile. -- -- ~kaeli~ When a clock is hungry, it goes back four seconds. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
Post Follow-up to this messageOn Tue, 21 Sep 2004 13:59:35 -0400, Frances Del Rio wrote: > .. what are .jar files, exactly?? they contain classes, right?? Besides classes though, they might contain a lot of things relavent to an application. Icons, help files, whatever. Jar files are a 'specialized' form of zip file, try renaming one and open it in a Zip program. I am not actually sure if specialized is the right term here, .jar's can have a main-class specified in the Manifest.mf stored in a particular directory of the zip, and can have the classes indexed and signed, but otherwise they are a zip file. Here are the JavaDocs for the JarFile class, note how it inherets directly from ZipFile. <http://java.sun.com/j2se/1.4.2/docs...ar/JarFile.html> HTH -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.lensescapes.com/ Images that escape the mundane
Post Follow-up to this messageok, I have another question about this: classes I write are in C:\.....\My Documents\myjava my java SDK/JRE is in C:\java (I renamed SDK folder from "j2sdk1.4.2_05" to "java" to keep things simple..) so when I type this into a class I'm writing... import java.io.*; import java.util.*; import java.text.*; how does my class know where to find the imported classes?? thank you for yr response.. Frances VisionSet wrote: > "Frances Del Rio" <fdr58@yahoo.com> wrote in message > news:2rb61mF17b510U1@uni-berlin.de... > > > > Now try and search for the file rt.jar > found it? > that is where the classes are. > > -- > Mike W > >
Post Follow-up to this message> ok, I have another question about this: > classes I write are in C:\.....\My Documents\myjava > > my java SDK/JRE is in C:\java (I renamed SDK folder from > "j2sdk1.4.2_05" to "java" to keep things simple..) > > so when I type this into a class I'm writing... > > import java.io.*; > import java.util.*; > import java.text.*; > > how does my class know where to find the imported classes?? thank you > for yr response.. Frances Take a look at your JDK directory. It contains a subdirectory called "jre" - it is where the JVM files are. Inside "jre", open "lib" directory. It contains the file "rt.jar". Use Winzip or similar programs to open it. Sort on the path... you'll see rt.jar is the jar file containing all the core classes. By default the compiler and JVM include this jar in the class path.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.