javac : command not found

Issues related to software problems.

javac : command not found

Postby 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
whatif
 
Posts: 45
Joined: 2011/02/10 01:36:21

Re: javac : command not found

Postby AlanBartlett » 2011/02/10 02:07:26

Welcome to the CentOS fora.

The recommended reading for all new members starts with the FAQ & Readme First.

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

Code: Select all
[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.
User avatar
AlanBartlett
Forum Moderator
 
Posts: 9172
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk

Re: javac : command not found

Postby 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?
whatif
 
Posts: 45
Joined: 2011/02/10 01:36:21

Re: javac : command not found

Postby AlanBartlett » 2011/02/10 21:26:45

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

That good. It confirms your current point release status.

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

That can be because you do not have the mlocate package installed or the cron / anacron package is not installed (or running). The tests are --

Code: Select all
[b]rpm -q mlocate vixie-cron anacron[/b]

Just install whichever package is not installed.

Code: Select all
[b]/sbin/chkconfig --list | grep cron[/b]

If one or both services is / are not running, enable it / them (via chkconfig) and start it / them (via service).

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

So if you do not have the jdk-1.6.0_22-fcs package (from Oracle / Sun) installed, you will not have that javac file. ;-)

any suggestions?

Sure. Go to here, download the latest JDK from under the Java Platform, Standard Edition heading, Take note of the installation instructions and see how it goes . . .
User avatar
AlanBartlett
Forum Moderator
 
Posts: 9172
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk

Re: javac : command not found

Postby whatif » 2011/02/11 19:18:59

Here is the output from the commands you suggested:

Code: Select all
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

the service command can't be found by bash. I'm new to linux, any more suggestions?
whatif
 
Posts: 45
Joined: 2011/02/10 01:36:21

javac : command not found

Postby 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
gerald_clark
 
Posts: 9248
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: javac : command not found

Postby whatif » 2011/02/11 19:43:50

I was logged in as root.
whatif
 
Posts: 45
Joined: 2011/02/10 01:36:21

Re: javac : command not found

Postby gerald_clark » 2011/02/11 19:50:09

Apparently, you did not use the proper method to become root.
Read the page.
gerald_clark
 
Posts: 9248
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: javac : command not found

Postby AlanBartlett » 2011/02/11 20:17:21

Here is the output from the commands you suggested:



the service command can't be found by bash.

Everything is o.k. You have all three packages and the services are running. I'll guess that the dbase, used by the locate 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 one-liner, which should be executed with root's powers --

Code: Select all
[b]cd /etc/cron.daily; for T in *; do ./$T; done[/b]

When the prompt returns (it may take a minute or more . . . depends upon your system), you should find that the locate command will now work.

For a working javac, you will need to complete what I suggested, above --

Go to here, download the latest JDK from under the Java Platform, Standard Edition heading, Take note of the installation instructions and see how it goes . . .

Do it now, whilst Gerald is still around and if you have any problems, he will be sure to guide you. ;-)
User avatar
AlanBartlett
Forum Moderator
 
Posts: 9172
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk

Re: javac : command not found

Postby 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?
whatif
 
Posts: 45
Joined: 2011/02/10 01:36:21

Next

Return to CentOS 5 - Software Support

Who is online

Users browsing this forum: No registered users and 1 guest