This discussion is archived
1 2 Previous Next 19 Replies Latest reply: May 27, 2012 6:07 PM by handat RSS

package javax.mail does not exist for centos 6.2

938489 Newbie
Currently Being Moderated
We have a centos 6.2 server. I have put the mail.jar into /usr/java/jdk1.7.0_03/jre/lib/ext folder. Then when I compile my java it gives me this error. The funny part I have done this last month on another server also with centos 6.2 and same java version all works fine. What could be missing here?
package javax.mail does not exist
import javax.mail.Message;
  • 1. Re: package javax.mail does not exist for centos 6.2
    sabre150 Expert
    Currently Being Moderated
    Looks to me like the javac being used is not the one you think it is. To find out use
    which javac
    and
    javac -version
    P.S. Why are you compiling on your server?
  • 2. Re: package javax.mail does not exist for centos 6.2
    938489 Newbie
    Currently Being Moderated
    Both the servers have the same java that is
    java version "1.7.0_03"
    Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
    Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
  • 3. Re: package javax.mail does not exist for centos 6.2
    sabre150 Expert
    Currently Being Moderated
    In your original post you indicated that you had a problem compiling and I suggest two diagnostic commands involving 'javac' yet for some reason you have reported the output from
    java -version
    which will not help in finding out why 'javac' does not work.
  • 4. Re: package javax.mail does not exist for centos 6.2
    938489 Newbie
    Currently Being Moderated
    Dear Sabre,
    The output is. I notice on my other machine is javac 1.7.0_03. What could be the cause here?
    javac -version
    javac 1.6.0_22
    Just to add on this are my steps which I did for both machines.

    rpm -Uvh /usr/local/jdk-7u3-linux-x64.rpm


    alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000

    alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000


    alternatives --config java

    Edited by: 935486 on May 21, 2012 6:48 PM

    Edited by: 935486 on May 21, 2012 6:53 PM
  • 5. Re: package javax.mail does not exist for centos 6.2
    EJP Guru
    Currently Being Moderated
    What could be the cause here?
    The cause is obviously that you have different versions of the JDK installed.
  • 6. Re: package javax.mail does not exist for centos 6.2
    938489 Newbie
    Currently Being Moderated
    Dear Ejp,
    Both machines were installed following the same steps. So what would have gone wrong then? Any bug here? The best part both are fresh machines and using same os centos 6.2
  • 7. Re: package javax.mail does not exist for centos 6.2
    sabre150 Expert
    Currently Being Moderated
    935486 wrote:
    Dear Ejp,
    Both machines were installed following the same steps. So what would have gone wrong then? Any bug here? The best part both are fresh machines and using same os centos 6.2
    I suggest that the two machines were not installed following the same steps. It is probable that all you have to do is use the Centos package manager to remove version 6 of the JRE. Failing that, make sure that the JDK7 bin directory is ahead of the JRE6 bin directory in your PATH environmental variable.
  • 8. Re: package javax.mail does not exist for centos 6.2
    EJP Guru
    Currently Being Moderated
    Both machines were installed following the same steps.
    Obviously not,* or the situation you describe would be impossible. Maybe someone reinstalled a later JDK afterwards? Who knows? It's pointless to ask us, they're your machines.
  • 9. Re: package javax.mail does not exist for centos 6.2
    938489 Newbie
    Currently Being Moderated
    Dear Sabre,
    I have checked the ./bash_profile and it have no existing JAVA_HOME path set. So then what is pointing to the jdk1.6 where else should I check? So where is path set then ? Just to add on here is the link I followed for my installation http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/. Finally I check with java -version is shows me the 1.7 but javac version is 1.6? What could have gone wrong? I just isntall the jdk must I also install the jre or it comes togeter with the jdk right?

    Edited by: 935486 on May 22, 2012 12:17 AM
  • 10. Re: package javax.mail does not exist for centos 6.2
    sabre150 Expert
    Currently Being Moderated
    935486 wrote:
    I have checked the ./bash_profile and it have no existing JAVA_HOME path set.
    JAVA_HOME is not involved when using 'javac' or 'java'' . Some applications such as Tomcat use JAVA_HOME but Java does not.
    What could have gone wrong?
    Simple - you installed Java 6 as well as Java 7 and you are picking up the wrong javac.
    I just isntall the jdk must I also install the jre or it comes togeter with the jdk right?
    What matters is not just what was installed but which the system finds first when you use the 'javac' command. This is where the PATH environment variable comes in. Spend some time learning about Linux/Unix.

    Now do you want to fix the problem or keep on erroneously insisting that the two systems were installed in an identical manner? They were not ! Fix the PATH.

    Bye
  • 11. Re: package javax.mail does not exist for centos 6.2
    938489 Newbie
    Currently Being Moderated
    Dear Sabre,
    Off course I want to solve the problem. OK I did some quick read up on path and below is some output. Based on this what should I do with the path now? Thank you.
    echo $PATH
    /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
  • 12. Re: package javax.mail does not exist for centos 6.2
    sabre150 Expert
    Currently Being Moderated
    Which does not help me help you because I have no idea where your Java 6 is installed since you still have not published the result of
    which javac
    You have a difference between two Centos system. For us to help isolate the difference we must be given some access to some fundamental information. You seem reluctant to provide this information. To start with, for both system, publish

    a) the value of the PATH environment variable,
    b) the result of 'which javac'
    c) the result of 'javac -version'

    Using the Centos package manager you should check both systems to see exactly what is installed. I can't remember the Centos command line command for getting a listing but it should not be too difficult to find.

    I'm finding it increasingly difficult to keep responding to this thread. You have to understand what you are doing with Centos. You have to understand the basics of Linux. You have to listen to what we say and take any non-destructive action that we suggest.
  • 13. Re: package javax.mail does not exist for centos 6.2
    938489 Newbie
    Currently Being Moderated
    Dear Sabre,
    Below is the proper machine information

    a) PATH
    /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
    b)which javac
    /usr/bin/javac
    c)javac -version
    javac 1.7.0_03

    Below is the information for the problematic server

    a) PATH
    -bash: /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory

    b)which javac
    /usr/bin/javac

    c)javac -version
    javac 1.6.0_22

    Thank you.
  • 14. Re: package javax.mail does not exist for centos 6.2
    Nitin Khare Expert
    Currently Being Moderated
    The problem here surely seems related to the way your environment has been setup and not much related to Java programming. Anyways, some of my observations are:
    Below is the information for the problematic server

    a) PATH
    -bash: /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory
    You can see that "No such file or directory" in your path which means you have something wrong for PATH in your ./bash_profile
    b)which javac
    /usr/bin/javac

    c)javac -version
    javac 1.6.0_22
    At the very first post on this thread you mentioned about placing mail.jar into "/usr/java/jdk1.7.0_03/jre/lib/ext" folder so ideally you should be using "javac" from "/usr/java/jdk1.7.0_03/bin" unless that directory itself has not been moved elsewhere. As you mentioned that your "javac" is being picked up from "/usr/bin" when it should be from "/usr/java/jdk1.7.0_03/bin"


    You may also need to find what all "javac" executable are present there in your system by executing something like
    find . -name javac
    from your root directory and then update your path to use the correct javac.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points