Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Error: could not find a Java JDK or JRE on your system

    SmartClient_v101p_2016-03-03_LGPL

    alam@alamltu2 ~/smartclient/smartclientSDK $ sudo ./start_embedded_server.sh
    [sudo] password for alam:

    Enable to auto-detect JAVA_HOME. Assuming 'java' is in PATH


    Error: could not find a Java JDK or JRE on your system.

    If you do not have Java installed, please download and install the JDK.
    If you do have Java installed, please set the JAVA_HOME environment
    variable to the base directory of the JDK.
    ------------------------------------------



    alam@alamltu2 ~/smartclient/smartclientSDK $ echo $JAVA_HOME
    /usr/lib/jvm/java-8-oracle/bin/java
    alam@alamltu2 ~/smartclient/smartclientSDK $ echo $JRE_HOME
    /usr/lib/jvm/java-8-oracle/jre/bin/java
    alam@alamltu2 ~/smartclient/smartclientSDK $ java -version
    java version "1.8.0_74"
    Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
    alam@alamltu2 ~/smartclient/smartclientSDK $

    --------------------------------

    sudo nano .bashrc

    export JAVA_HOME=/usr/lib/jvm/java-8-oracle/bin/java
    export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre/bin/java
    export PATH=$PATH:$HOME/bin:JAVA_HOME:JRE_HOME

    ------------------------

    What's wrong with my java?. pls help.. thanks.

  • #2
    JAVA_HOME and JRE_HOME shouldn't point to the executables - they should point to the JDK and JRE, respectively. So in your case,

    Code:
    export JAVA_HOME=/usr/lib/jvm/java-8-oracle
    export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
    The path should contain ${JAVA_HOME}/bin. Your path above doesn't appear to be properly referring to the variables. You should look for more details on the web - bash's man page should cover variable use. This forum really isn't intended for helping with that.
    Last edited by Isomorphic; 12th Mar 2016, 22:45.

    Comment


    • #3
      Originally posted by Isomorphic View Post
      JAVA_HOME and JRE_HOME shouldn't point to the executables - they should point to the JDK and JRE, respectively. So in your case,

      Code:
      export JAVA_HOME=/usr/lib/jvm/java-8-oracle
      export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
      The path should contain ${JAVA_HOME}/bin. Your path above doesn't appear to be properly referring to the variables. You should look for more details on the web - bash's man page should cover variable use. This forum really isn't intended for helping with that.
      ----------------------------------------

      alam@alamltu2 ~ $ echo $JAVA_HOME
      /usr/lib/jvm/java-8-oracle
      alam@alamltu2 ~ $ echo $JRE_HOME
      /usr/lib/jvm/java-8-oracle/jre
      alam@alamltu2 ~ $ echo $PATH
      /home/alam/.rbenv/plugins/ruby-build/bin:/home/alam/.rbenv/shims:/home/alam/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-7-oracle/bin:/usr/lib/jvm/java-7-oracle/db/bin:/usr/lib/jvm/java-7-oracle/jre/bin:/usr/local/bin/ignition:/usr/local/bin/ignition:~/.composer/vendor/bin:/home/alam/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/jre/bin
      ---------------------

      export JAVA_HOME=/usr/lib/jvm/java-8-oracle
      export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
      export PATH=$PATH:$HOME/bin:${JAVA_HOME}/bin:${JRE_HOME}/bin
      ----------------------------

      alam@alamltu2 ~/smartclient/smartclientSDK $ sudo ./start_embedded_server.sh
      [sudo] password for alam:

      Enable to auto-detect JAVA_HOME. Assuming 'java' is in PATH


      Error: could not find a Java JDK or JRE on your system.

      If you do not have Java installed, please download and install the JDK.
      If you do have Java installed, please set the JAVA_HOME environment
      variable to the base directory of the JDK.
      -----------------------------------------

      The error message above is very confusing and beyond my comprehension. I am running Netbeans, Eclipse, Ignition SCADA, Tomcat and several java based client/server packages. All could detect $JAVA_HOME perfectly. I wonder, why a genius product like smartclient is unable to detect $JAVA_HOME despite following every permutation and combination recommended by the book of Java?. My machine is configured for very high end development and i can NOT mess around with my machine to make smartclient submit to my will by brute force :)

      Comment


      • #4
        Originally posted by Isomorphic View Post
        JAVA_HOME and JRE_HOME shouldn't point to the executables - they should point to the JDK and JRE, respectively. So in your case,

        Code:
        export JAVA_HOME=/usr/lib/jvm/java-8-oracle
        export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
        The path should contain ${JAVA_HOME}/bin. Your path above doesn't appear to be properly referring to the variables. You should look for more details on the web - bash's man page should cover variable use. This forum really isn't intended for helping with that.
        Problem solved:

        Execute without sudo.

        alam@alamltu2 ~/smartclient/smartclientSDK $ ./start_embedded_server.sh

        ----------------------

        1. Eventhough the "sudo echo $JAVA_HOME" detects the $JAVA_HOME path, it doesn't detect in the script. I need to look deeper..

        alam@alamltu2 ~ $ sudo echo $JAVA_HOME
        /usr/lib/jvm/java-8-oracle
        alam@alamltu2 ~ $ echo $JAVA_HOME
        /usr/lib/jvm/java-8-oracle

        2. I have setup JAVA environment for all users...

        sudo nano /etc/profile

        .......
        export JAVA_HOME=/usr/lib/jvm/java-8-oracle
        export JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
        export PATH=$PATH:$HOME/bin:${JAVA_HOME}/bin:${JRE_HOME}/bin

        ---------------------------------

        3. and updated the profile....

        alam@alamltu2 ~ $ . /etc/profile
        -------------------

        I have explained my troubleshooting steps so that it may help others as well... Thanks.


        Comment


        • #5
          There's a slight typo in the error message - it should say, "Unable to auto-detect JAVA_HOME" - but the advice is sound. You need to define JAVA_HOME in a way that's visible to the script. We're not sure why you're running start_embedded_server.sh with sudo, but when you do that it runs as root, without the current user's environment variables. It's not really the purpose of this forum to teach basics, but you could use the env command to pass environment variables:

          Code:
          sudo env JAVA_HOME=/usr/lib/jvm/java-8-oracle ./start_embedded_server.sh
          or you could use various sudo command-line options - for example"-E" passes through the environment variables from the current shell, and there's another option available that could run root's login script. You should be able to find all the info you need on sudo and env from their man pages, or on the web.

          Comment


          • #6
            Thanks. Problem solved.

            The best way to identify $JAVA_HOME by sudo command in bash scripts is to run it with -E option. This preserves the environment.

            alam@alamltu2 ~/smartclient/smartclientSDK $ sudo -E ./start_embedded_server.sh
            --------------------------



            I suggest to update this above command in the user manual.

            Comment

            Working...
            X