Results 1 to 3 of 3
- 06-27-2012, 11:30 PM #1Member
- Join Date
- Apr 2012
- Rep Power
- 06-27-2012, 11:44 PM #2
Re: import class java where is it?
It is part of the java installation process that the jar and zip files with the java classes are located where the javac and java commands can find them. It is not something you need to worry about unless you go into the jre and jdk folders and start moving files around.If you don't understand my response, don't ignore it, ask a question.
- 06-28-2012, 02:44 AM #3Moderator
- Join Date
- Feb 2009
- New Zealand
- Rep Power
Re: import class java where is it?how does the compiler know where the java classes?
For other classes - the classes you, yourself, create or third party libraries - the java executables (java, javac, etc) will look in a series of places known as the classpath. Typically the classpath is told to the compiler or the runtime when it starts. Often IDEs hide the setting of this classpath within what they call "project settings", but it important to realise that the Java "way of doing things" is different from other languages where the separate parts of a programs are specially "linked" at the time they are compiled. Having a classpath (=="place where classes and other resources are located") that is set at runtime results in a great deal of flexibility. For instance the classes can come from all over the internet, be stored in archives or databases etc, and be altered somewhat independently of one another.
To begin with it is enough to be confident that classes are found. But, sooner or later, you will want to configure an IDEs "project settings", or compile your programs from the command line and setting this classpath will be part of that. If you understand what this classpath is (ie it is the answer to your question!) then you will be in a good position to understand the documentation and the advice you might get in forums like this about setting it.
I might add that the classpath, understood in this general sense, is different from the CLASSPATH environment variable which is supposed to be a general purpose classpath that all java executables will use. Advice you often see on the web to set this variable to one value or another is not good advice, imho, in as much as it fights against the idea of gaining flexibility by setting the classpath when the executable is run.
- By daydreamer in forum New To JavaReplies: 7Last Post: 10-04-2010, 11:32 PM
- By Dipke in forum New To JavaReplies: 5Last Post: 08-09-2010, 10:54 AM
- By pos in forum JavaServer Pages (JSP) and JSTLReplies: 20Last Post: 04-06-2010, 02:51 PM
- By Splat in forum New To JavaReplies: 5Last Post: 10-13-2009, 04:53 AM