How to set CLASSPATH, or PATH

Joined
Jan 23, 2010
Messages
53
Reaction score
0
Points
6
Your Mac's Specs
MacBook Air / 1.86GHz / 2 GB / Version 10.6.2
Hello,

I have Mac Air Book and am using it to study Java programming for a certification exam (required by my job). So far when I write code and save it to a directory, it complies. Now it seems I need to learn about CLASSPATHs and setting them. When I open the terminal and type in

Code:
echo $CLASSPATH

I get a blank output

however, if I type in

Code:
echo $PATH

I get some directories that end in /bin


Questions
1. How do I set and edit CLASSPATH, or PATH
2. Does the Mac OS use CLASSPATH, or PATH, or both


Please point me in the correct direction
 

rman


Retired Staff
Joined
Dec 24, 2002
Messages
12,637
Reaction score
168
Points
63
Location
Los Angeles, California
Your Mac's Specs
14in MacBook Pro M1 Max 32GB 2TB
PATH is an environmental variable. What you saw was your search path for UNIX command/binaries/applications.

If you are running borne/korne shell then do the following:

CLASSPATH=
export CLASSPATH

or

export CLASSPATH=

put what ever you want after the equals sign
 
Joined
Apr 9, 2009
Messages
2,073
Reaction score
68
Points
48
Location
Ithaca NY
Your Mac's Specs
13 inch alMacBook 2GHz C2D 4G DDR3, 1.25GHz G4 eMac
The $PATH environment variable sets all of the locations where your system looks for scripts, so that if you just type "name_of_script" and nothing else (like "open 'file/path/of/script") it will still open.

You're running BASH i am assuming, since it is the default shell of the OS X command line. I highly recommend installing VirtualBox and Ubuntu 10.04 though to mess around with shell scripting and other programming. That way you won't eff your computer.

from linuxcommand.org

You can add directories to your path with the following command, where directory is the name of the directory you want to add:

[me@linuxbox me]$ export PATH=$PATH:directory

A better way would be to edit your .bash_profile file to include the above command. That way, it would be done automatically every time you log in.

Most modern Linux distributions encourage a practice in which each user has a specific directory for the programs he/she personally uses. This directory is called bin and is a subdirectory of your home directory. If you do not already have one, create it with the following command:

[me@linuxbox me]$ mkdir bin

Note in OS X the file is not ~/.bash_profile but ~/.profile
 
OP
jhoomjhoom
Joined
Jan 23, 2010
Messages
53
Reaction score
0
Points
6
Your Mac's Specs
MacBook Air / 1.86GHz / 2 GB / Version 10.6.2
Thank you for the advice.

Fortunately, I already have VirtualBox loaded with Ubuntu, will code from there.
 
Joined
Apr 9, 2009
Messages
2,073
Reaction score
68
Points
48
Location
Ithaca NY
Your Mac's Specs
13 inch alMacBook 2GHz C2D 4G DDR3, 1.25GHz G4 eMac
Excellent! Might wanna up your RAM to get that ubuntu machine really humming. I've got 2 gigs of ram to my ubuntu VM and 128MB of VRAM for it, it's pretty sweet. I've been playing around in OS X, so I've customized my terminal and added some aliases and stuff... like, i type "code" and out pops smultron - added CLICOLORS (enabled by default in ubuntu) and customized the scheme a bit... but i really need to get back into the linux VM tomorrow night and start working again. :)
 
OP
jhoomjhoom
Joined
Jan 23, 2010
Messages
53
Reaction score
0
Points
6
Your Mac's Specs
MacBook Air / 1.86GHz / 2 GB / Version 10.6.2
Wow, that sounds like fun :)
 
Joined
Jul 2, 2007
Messages
3,494
Reaction score
204
Points
63
Location
Going Galt...
Your Mac's Specs
MacBookAir5,2:10.13.6-iMac18,3:10.13.6-iPhone9,3:11.4.1
If you want to have some real fun, type env at the command line. You should get every good idea of most of the items applied to your user's session. God luck with your certification!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top