javac : command not found

Issues related to software problems.
whatif
Posts: 45
Joined: 2011/02/10 01:36:21

javac : command not found

Post by whatif » 2011/02/10 01:44:03

I have installed CentOS 5.5 and included the java development package. When I typed java -version, I got java 1.6.0. The problem is with the javac command, which is not found. I tried the following:

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_23/bin/java 2

/usr/sbin/alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.6.0_23/jre/bin/javaws 2

/usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_23/bin/javac 2

what else should I do to get javac to work?

Thanks,
Mike

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: javac : command not found

Post by AlanBartlett » 2011/02/10 02:07:26

Welcome to the [i]CentOS[/i] fora.

The recommended reading for all new members starts with the [url=https://www.centos.org/modules/newbb/viewforum.php?forum=47]FAQ & Readme First[/url].

With regards to your issue, I took a quick look at [b]Ned[/b]'s system and this is what I saw --

[code]
[ajb@Quad ~]$ rpm -q centos-release
centos-release-5-5.el5.centos
[ajb@Quad ~]$ locate bin/javac
/usr/java/jdk1.6.0_22/bin/javac
[ajb@Quad ~]$ ll $(locate bin/javac)
-rwxr-xr-x 1 root root 52280 Sep 15 09:35 /usr/java/jdk1.6.0_22/bin/javac
[ajb@Quad ~]$ rpm -qf /usr/java/jdk1.6.0_22/bin/javac
jdk-1.6.0_22-fcs
[ajb@Quad ~]$ rpm -qi jdk-1.6.0_22-fcs
Name : jdk Relocations: /usr/java
Version : 1.6.0_22 Vendor: Oracle and/or its affiliates.
Release : fcs Build Date: Wed 15 Sep 2010 11:28:35 BST
Install Date: Thu 14 Oct 2010 19:41:27 BST Build Host: jdk-lin-amd64.sfbay.sun.com
Group : Development/Tools Source RPM: jdk-1.6.0_22-fcs.src.rpm
Size : 146606343 License: Copyright (c) 2010, Oracle and/or its affiliates.
Signature : (none)
Packager : Java Software <jre-comments@java.sun.com>
URL : http://java.sun.com/
Summary : Java(TM) Platform Standard Edition Development Kit
Description :
The Java Platform Standard Edition Development Kit (JDK) includes both
the runtime environment (Java virtual machine, the Java platform classes
and supporting files) and development tools (compilers, debuggers,
tool libraries and other tools).

The JDK is a development environment for building applications, applets
and components that can be deployed with the Java Platform Standard
Edition Runtime Environment.
[ajb@Quad ~]$ /usr/sbin/alternatives --display java
java - status is manual.
link currently points to /usr/lib/jvm/jre-1.4.2-gcj/bin/java
/usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1420
slave keytool: /usr/lib/jvm/jre-1.4.2-gcj/bin/keytool
slave rmiregistry: /usr/lib/jvm/jre-1.4.2-gcj/bin/rmiregistry
slave jre_exports: /usr/lib/jvm-exports/jre-1.4.2-gcj
slave jre: /usr/lib/jvm/jre-1.4.2-gcj
Current `best' version is /usr/lib/jvm/jre-1.4.2-gcj/bin/java.
[ajb@Quad ~]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-48)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[/code]

whatif
Posts: 45
Joined: 2011/02/10 01:36:21

Re: javac : command not found

Post by whatif » 2011/02/10 19:43:16

Thank you for taking the time to help with this issue.


I tried the commands you used and here is the output:

rpm -q centos-release
centos-release-5-5.el5.centos

locate bin/javac
locate : can not open '/var/lib/mlocate/mlocate.db' : no such file or directory

rpm -qf /usr/java/jdk1.6.0_22/bin/javac
error : file /usr/java/jdk1.6.0_22/bin/javac : No such file or directory


any suggestions?

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: javac : command not found

Post by AlanBartlett » 2011/02/10 21:26:45

[quote]
rpm -q centos-release
centos-release-5-5.el5.centos
[/quote]
That good. It confirms your current point release status.

[quote]
locate bin/javac
locate : can not open '/var/lib/mlocate/mlocate.db' : no such file or directory
[/quote]
That can be because you do not have the [i]mlocate[/i] package installed or the [i]cron / anacron[/i] package is not installed (or running). The tests are --

[code]
[b]rpm -q mlocate vixie-cron anacron[/b]
[/code]
Just install whichever package is not installed.

[code]
[b]/sbin/chkconfig --list | grep cron[/b]
[/code]
If one or both services is / are not running, enable it / them (via [b]chkconfig[/b]) and start it / them (via [b]service[/b]).

[quote]
rpm -qf /usr/java/jdk1.6.0_22/bin/javac
error : file /usr/java/jdk1.6.0_22/bin/javac : No such file or directory
[/quote]
So if you do not have the [b]jdk-1.6.0_22-fcs[/b] package (from [i]Oracle / Sun[/i]) installed, you will not have that [i]javac[/i] file. ;-)

[quote]
any suggestions?
[/quote]
Sure. Go to [url=http://www.oracle.com/technetwork/java/javase/downloads/index.html]here[/url], download the latest [b]JDK[/b] from under the [i]Java Platform, Standard Edition[/i] heading, Take note of the installation instructions and see how it goes . . .

whatif
Posts: 45
Joined: 2011/02/10 01:36:21

Re: javac : command not found

Post by whatif » 2011/02/11 19:18:59

Here is the output from the commands you suggested:

[code]
rpm -q mlocate vixie-cron anacron
mlocate-0.15-1.el5.2
vixie-4.1-77.el5_4.1
anacron-2.3-45.el5.centos

/sbin/chkconfig --list | grep cron
anacron 0 : off 1 : off 2 : on 3 : on 4 : on 5 : on 6 : off
crond 0 : off 1 : off 2 : on 3 : on 4 : on 5 : on 6 : off
[/code]
the service command can't be found by bash. I'm new to linux, any more suggestions?

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

javac : command not found

Post by gerald_clark » 2011/02/11 19:35:07

You must be root to run the service command.
Please read the following page.
http://wiki.centos.org/TipsAndTricks/BecomingRoot

whatif
Posts: 45
Joined: 2011/02/10 01:36:21

Re: javac : command not found

Post by whatif » 2011/02/11 19:43:50

I was logged in as root.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: javac : command not found

Post by gerald_clark » 2011/02/11 19:50:09

Apparently, you did not use the proper method to become root.
Read the page.

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: javac : command not found

Post by AlanBartlett » 2011/02/11 20:17:21

[quote]
Here is the output from the commands you suggested:

[i][/i]

the service command can't be found by bash.
[/quote]
Everything is o.k. You have all three packages and the services are running. I'll guess that the dbase, used by the [i]locate[/i] command, is not populated because the system has not been running long enough to perform the deed. :-)

To get things started, here is a brash [i]one-liner[/i], which should be executed with [i]root[/i]'s powers --

[code]
[b]cd /etc/cron.daily; for T in *; do ./$T; done[/b]
[/code]
When the prompt returns (it may take a minute or more . . . depends upon your system), you should find that the [i]locate[/i] command will now work.

For a working [i]javac[/i], you will need to complete what I suggested, above --

[quote]
Go to [url=http://www.oracle.com/technetwork/java/javase/downloads/index.html]here[/url], download the latest JDK from under the [i]Java Platform, Standard Edition[/i] heading, Take note of the installation instructions and see how it goes . . .
[/quote]
Do it now, whilst [b]Gerald[/b] is still around and if you have any problems, he will be sure to guide you. ;-)

whatif
Posts: 45
Joined: 2011/02/10 01:36:21

Re: javac : command not found

Post by whatif » 2011/02/11 23:59:05

Thank you very much guys!

It worked finally. I downloaded the jdk from sun.com and installed successfully. Also, the service command worked. I didn't know I have to log in this way!

The installation created several rpms on my desktop, can I delete them?

Do you have any explanation as to why the java command worked and javac didn't even though I installed the java development package?

Do you suggest any books or online resources for a beginner?

Post Reply