Wrox Programmer Forums
|
BOOK: Beginning Java 2
This is the forum to discuss the Wrox book Beginning Java 2, SDK 1.4 Edition by Ivor Horton; ISBN: 9780764543654
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Java 2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 28th, 2005, 01:29 PM
Registered User
 
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default classpath

 kindly tell everything related to classpath n other
  environment variables available for Java2 in windows 98.
  wats the role of classpath while using packages.


 
Old March 28th, 2005, 11:35 PM
Authorized User
 
Join Date: Jul 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by ekta
  kindly tell everything related to classpath n other
  environment variables available for Java2 in windows 98.
Sorry, I can't answer that, although I too use win98, so I might be able to answer more specific questions. I suggest you read the book.

Quote:
quote:wats the role of classpath while using packages.
I don't know if you've ever tried to compile and execute a file that is part of a package, but Java doesn't make it very easy. Given this directory structure:

C:
--javaPrograms folder
------Pack1 folder
------------DemoA.java

The only way I have figured out to compile(javac) a source file(.java) is to change the DOS prompt to the folder containing the source file:

C:\javaPrograms\Pack1>

and then compiling:

C:\javaPrograms\Pack1> javac DemoA.java

When you are executing(java) your program, the classpath tells java where to look for the package folder. One way you can tell java where to look for the package folder is with the classpath flag. In the classpath flag, you specify the folder that contains the package folder:

C:\javaPrograms\Pack1> java -classpath C:\javaPrograms Pack1.DemoA

Or, you can permanently set the CLASSPATH environment variable, which does the same thing as the classpath flag, but it is a permanent setting. That means java will search all the directories listed under CLASSPATH for the package, and you don't need to include the classpath flag in the java command to execute your program.

You should note that if you switch the DOS prompt to the directory/folder that contains the package folder, you can execute your program without specifying a classpath flag or setting the CLASSPATH environment variable. For instance, in the above example, if you change the DOS prompt:

C:\javaPrograms\Pack1> cd ..

to get the prompt:

C:\javaPrograms>

You can execute the program from there like this:

C:\javaPrograms> java Pack1.DemoA





Similar Threads
Thread Thread Starter Forum Replies Last Post
classpath? abdi Java GUI 1 December 8th, 2004 04:44 PM
chapter1 CLASSPATH jeanne JSP Basics 2 August 11th, 2004 12:45 AM
setting classpath aadz5 JSP Basics 1 July 28th, 2004 04:04 PM
how to set the classpath sxj1209 JSP Basics 3 March 29th, 2004 04:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.