File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes Setting path in linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Setting path in linux" Watch "Setting path in linux" New topic
Author

Setting path in linux

swapna nyathani
Greenhorn

Joined: Mar 16, 2006
Posts: 21
Hi,
I am new to linux and i want to run java code in linux.
Am using Redhat Enterprise linux 5.
I think java is installed (i mean built in)


When i write a java code in vi editor, its syntax is recognized, example keywords are highlighted.
i know how to run.For example, if 'sample' is java file name,
> javac sample.java
> java sample
will give output.
but the error i am getting is : \bash ' javac' is not a command
i think the problem might be that path is not set.
Can anyone tell me how to set path.

Thanks,
swapna.

swapna
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

I am not sure that Java is built-in, but you can find out by entering:

java -version

Also, in RHEL Java is usually installed at /usr/java, you can look in there to see which one is installed.

To set PATH, open the ~/.bashrc file and add lines like this:



JBoss In Action
swapna nyathani
Greenhorn

Joined: Mar 16, 2006
Posts: 21

Thanks for your reply Peter.

As you said ' To set PATH, open the ~/.bashrc file '
i want to know where is 'bashrc' located.

And i can see that java is installed in 'root/bin/java'.

I have ' KDevelop' an IDE used for multiple languages installed in linux.
how can i run java in it.
please help.

Thanks,
Swapna.






Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

As you said ' To set PATH, open the ~/.bashrc file '
i want to know where is 'bashrc' located.

Um, the tilde (~) equates to your home directory, so ~/.bashrc is the location of the file. If the file does not exist, you can create it.

[code]And i can see that java is installed in 'root/bin/java'.
I assume that is a type and you mean to type "/root/bin/java".
Are you logged in as root by any chance. If so, don't do that. You should have a separate user account that you always log into. And I am also guessing that you downloaded the *.bin file, and not the *-rpm.bin file, for Sun's web site.

I have ' KDevelop' an IDE used for multiple languages installed in linux.
how can i run java in it.

I know nothing about KDevelop - I use Eclipse. Perhaps someone who uses KDevelop can help.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

swapna valupadasu wrote:
but the error i am getting is : \bash ' javac' is not a command
i think the problem might be that path is not set.
Can anyone tell me how to set path.


You should be precise when reporting errors, because sometimes a single blank makes a difference. The name of the compiler is 'javac', not ' javac', but I guess this is a reporting error.

The backslash in front of bash is surprising too.

'root/bin' looks like a misinterpretation. There is the homedirectory of root, named '/root', and there is the root of the filesystem named '/', but often simply named root too.

But javac is normally put to /usr/bin/javac, not /bin/javac by the installationprocess.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting path in linux