Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

API question
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




Report this thread to moderator Post Follow-up to this message
Old Post
Frances Del Rio
09-21-04 08:59 PM


Re: API question
"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



Report this thread to moderator Post Follow-up to this message
Old Post
VisionSet
09-21-04 08:59 PM


Re: API question
ok, 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
>
>
>


Report this thread to moderator Post Follow-up to this message
Old Post
Frances Del Rio
09-21-04 08:59 PM


Re: API question
In 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


Report this thread to moderator Post Follow-up to this message
Old Post
kaeli
09-21-04 08:59 PM


Re: API question
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
Andrew Thompson
09-21-04 08:59 PM


Re: API question
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


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
>
>


Report this thread to moderator Post Follow-up to this message
Old Post
Frances Del Rio
09-23-04 08:56 AM


Re: API question
> 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.



Report this thread to moderator Post Follow-up to this message
Old Post
KC Wong
09-23-04 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:20 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.