aspose file tools*
The moose likes Beginning Java and the fly likes can someone tell me how to set the classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "can someone tell me how to set the classpath" Watch "can someone tell me how to set the classpath" New topic
Author

can someone tell me how to set the classpath

pat foran
Greenhorn

Joined: Sep 07, 2007
Posts: 6
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

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
pat foran
Greenhorn

Joined: Sep 07, 2007
Posts: 6
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

Joined: Aug 31, 2004
Posts: 11343

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

Joined: Sep 07, 2007
Posts: 6
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

Joined: Aug 31, 2004
Posts: 11343

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

Joined: Sep 07, 2007
Posts: 6
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

Joined: Aug 16, 2005
Posts: 14150
    
  18

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
pat foran
Greenhorn

Joined: Sep 07, 2007
Posts: 6
thankssss
pat foran
Greenhorn

Joined: Sep 07, 2007
Posts: 6
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

Joined: Oct 13, 2005
Posts: 38865
    
  23
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can someone tell me how to set the classpath