This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes noob needs help with path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "noob needs help with path" Watch "noob needs help with path" New topic
Author

noob needs help with path

Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
Hi,
first of al I�ve to appologice for my english, beeng from Sweden..

I�ve just installed jdk-1_5_0_06-windows on my xp pro. In the the book it says: "add an entry to your path enviroment variable that points to the /bin directory inside the main Java directory"
How do I do that?
the bin is installed to:
c:\java\bin

Thx in advance
Yours
Peter_the_swede
Jorg Klein
Ranch Hand

Joined: Feb 13, 2006
Posts: 33
Hi Peter, your english is fine for me, its not my mother tongue either and posting on english forums is great for your english.

Well your question.
Just follow the steps on the website: http://www.cs.usask.ca/grads/wew036/latex/env.html

Good Luck!
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
Thx Jorge for your kindness, but still I cant get the javac working...
It oppens up a window, but after 1 sec it closes down, and will not open once more

in "HOME" should I put c:\Java or c:\Java\bin?

thx
/Peter
Kamesh Loganathan
Greenhorn

Joined: Jan 21, 2006
Posts: 20
Hi Pal,
I think u have to set
JAVA_HOME to c:\java\bin
path to c:\java\bin
and
classpath to c:\java\bin

It should work
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
Thx Kamesh
but how and where do I that?

//Peter
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Do you know how to open a command line on your system?
I can't remember it exactly, but try Start -> Run. Then type cmd or command

Once on command line, what happens when you type javac ?
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Originally posted by ptr lks:
Thx Kamesh
but how and where do I that?

//Peter


If you are using Windows 2000 you can follow the following steps:

Go to your Desktop -> Right click on My computer -> Select Properties -> Selected Advanced Tab -> Select Environment Variables -> Click on New ->
Add the values Variable Name as JAVA_HOME and
Variable Value c:\java\bin
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
Sonny:
"javac is a intern command, a extern command or a program"
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
Tx
Originally posted by KJ Reddy:


If you are using Windows 2000 you can follow the following steps:

Go to your Desktop -> Right click on My computer -> Select Properties -> Selected Advanced Tab -> Select Environment Variables -> Click on New ->
Add the values Variable Name as JAVA_HOME and
Variable Value c:\java\bin


Can I do the same in xp pro?
and should I create al 3 ( i.e. JAVA_HOME, path, and classpath)?

thx in advance
//Peter
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
ok... now I�ve done as suggested:
does it matter where to save my .java file?
How do I run javac?

thx
//peter
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Originally posted by ptr lks:
ok... now I�ve done as suggested:
does it matter where to save my .java file?
How do I run javac?

thx
//peter


Yes it matters.
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
Originally posted by KJ Reddy:


Yes it matters.


where should I save?

ths
//Peter
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130
Ptr,

If you installed the JDK to c:\java, then your JAVA_HOME environment variable should be set to this path (without the "bin"). More importantly the PATH environment variable should be set c:\java\bin. You do this in the same manner - however when you edit this variable (it probably already exists), make sure that you go to the end of PATH string, type in a semi-colon [;] and then type in c:\java\bin.

The classpath is a different issue altogether. For the time being, keep things simple and make sure that you change the current directory to the directory where your java source is before issuing the javac command.

When you get this working, then you would be in a better position to start playing around with classpath if you wish.

BTW, I'd strongly advise you to change your display name as well to comply with the JavaRanch naming policy.

Read this for more info:

Naming Policy

Regards,
JD

[ February 15, 2006: Message edited by: John Dell'Oso ]
[ February 15, 2006: Message edited by: John Dell'Oso ]
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
thx JD,
maybe I�m slow to understand so:
Originally posted by John Dell'Oso:

If you installed the JDK to c:\java, then your JAVA_HOME environment variable should be set to this path (without the "bin").

You mean that I create a new variable name: JAVA_HOME value: c:\Java
Originally posted by John Dell'Oso:
More importantly the PATH environment variable should be set c:\java\bin. You do this in the same manner - however when you edit this variable (it probably already exists), make sure that you go to the end of PATH string, type in a semi-colon [;] and then type in c:\java\bin.

Should I create a new or should I use the existing?
and if using the exisitng, do I need to delete the one I�ve created?
Originally posted by John Dell'Oso:

The classpath is a different issue altogether. For the time being, keep things simple and make sure that you change the current directory to the directory where your java source is before issuing the javac command.

When you get this working, then you would be in a better position to start playing around with classpath if you wish.

I don�t really understand what you mean??

If I�ve a file"Party.java" how do I compile this? (i.e how do I run the javac?)

thx
//Peter
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Originally posted by Peter Lelkes:
thx JD,
maybe I�m slow to understand so:
I don�t really understand what you mean??

If I�ve a file"Party.java" how do I compile this? (i.e how do I run the javac?)

thx
//Peter


If you set the path correctly, you can compile by:

javac Party.java

and you can run that class by:

java Party
John Dell'Oso
Ranch Hand

Joined: Apr 08, 2004
Posts: 130
Peter,

You mean that I create a new variable name: JAVA_HOME value: c:\Java


Yes. BTW, I don't think you even need this variable - I can't remember if this variable is created and set when you install the JDK.

Should I create a new or should I use the existing?
and if using the exisitng, do I need to delete the one I�ve created?


If the PATH variable doesn't exist, then create it and set its value to c:\java\bin. If it does, then definitely don't delete it as other apps on your PC may not work correctly. As I said in my previous post, add the value "c:\java\bin" to the existing value using a semi-colon as the separator.

Now I'm assuming that you are trying to compile and run java programs from the command line. If you have a directory called c:\myjava where you store your java source, then you would first change your working directory to this directory (using the DOS cd command) and then issue the command:

javac Party.java

If this works, then you should see a file in the same directory called Party.class - to run this java program, you issue the following command

java Party

I hope that clears up a few things for you.

Regards,
JD
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
See if this tutorial helps you get going. Let me know if the first couple steps are too big a leap from where you are now and we'll try to help bridge the gap. If it gets more advanced than you want to dig into, just stop.
[ February 15, 2006: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Peter Lelkes
Greenhorn

Joined: Jan 30, 2006
Posts: 9
I think it�s working...
but I got the following errot:
Exception in thread "main" java.lang.NoSuchMethodError: main

with the code from the book
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
When you say "java Party" you start the Java program - the JVM - and tell it to run the Party class. To do that it looks for a method like this:

public static void main( String[] args )

The only part that you can change is the name of the string array. It doesn't have to be "args". But the rest of that signature has to be there. main() is a perfectly normal method. The only thing unusual about it is that the JVM looks for it.

It's common for main() to make an instance of the class it's in and run some tests, a demonstration or the real program.


Did you have a main() where you showed "// more code here" ?? If not, that's what you need!
 
GeeCON Prague 2014
 
subject: noob needs help with path