Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can someone tell me how to set the classpath

 
pat foran
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im in a computer programing class and i dont know anything about this and i have java programming fourth edition and i need to set the classpath or something like and i have no idea how
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat,
I'm going to move this to our Java In General (Beginner) forum where classpath and javac issues are discussed.
While you're waiting for answers, you might want to check our our FAQ for that forum. It has lots of tips for doing this.

http://faq.javaranch.com/java/JavaBeginnersFaq
[ September 07, 2007: Message edited by: Ben Souther ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pat foran:
...i need to set the classpath or something like...

First, you need to be sure: Is it really the CLASSPATH? Or is it the PATH? These are very different things that are often confused.

What is your reason for setting this?
 
pat foran
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my professor said make sure you set the classpath first and i have a txt book but it doesnt help me and no one else can so i thought id ask people here
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pat foran:
my professor said make sure you set the classpath first...

Set it to what? Do you have third-party classes stored somewhere?
 
pat foran
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im sorry but i have no idea what that means all i know is this is a computer programming class and my professor said that this is the most basic class but i have no files saved before this the text book came with the software which i installed and now im on the OS prompt and the book says i need to set the class and classpath options which i dont know how to do...sorry if i confuse you with this
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. Let's make sure the PATH is set, and then figure out whether you need a CLASSPATH.

1) What operating system are you running?

2) Do you know what exactly you installed from the CD?

3) Have you downloaded/installed anything from java.sun.com?
 
pat foran
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ummi just installed java standard edition 6 i believe and i didnt download anything else. and i havent set up anything yet. ive tried to type set classpath=. in the OS prompt but it wont do anything. that is what the book tells me to do but it just doesnt work
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you also read and follow the installation instructions?

You do not need to set the classpath, unless you have third-party libraries that you need in your programming project. The classpath tells Java where to find those libraries.

You might need to set the PATH environment variable. The JDK installation instructions (link above) explain how to do that (in step 4).

Also have a look at the JavaRanch Java Beginners FAQ.
 
pat foran
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankssss
 
pat foran
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so i read that link that you gave me and did that but now im trying to do the Hello World app. and i type javac myhello.java in the OS prompt and it says javac is not recognized
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Jesper Young has already told you:

If you can't remember where you installed Java, try a search for the javac file. It might be hidden, and lives in various places: in Windows I have it in

c:\Program Files\Java\jdk1.6.0_02\bin

and on Linux (I think)

/usr/java/jdk1.6.0_01/bin/

Look at this website about common problems from the Java tutorial. The first problem appears to be what you describe, and (as Marc Weber and Jesper Young have already said) is most likely that you need to add the location of java, javac, etc to the PATH. There is a link to setting the PATH on that website.

That appears to be for Windows. If you are using an old version of Windows, come back to us. If you are using Linux, you write something like

export PATH=/usr/java/jdk1.6.0_01/bin/:$PATH
and return on a shell/terminal and the PATH will remain set until you close that shell.
You can also edit the .bashrc or a similar file on Linux with a text editor, remembering to keep a backup copy of the original text just in case!

You will probably find the program works nicely once you have the PATH set up.

Good luck. CR
[edit]Minor spelling corrections[/edit]
[ September 09, 2007: Message edited by: Campbell Ritchie ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic