AWS Codedeploy fails with JAVA_HOME error - java

Have installed java 8 and
Java -version
yields
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Having a AfterInstall script under hooks which simply has
cd $HOME/workspace
mvn clean install
AWS codedeploy is failing with following error
{\"message\":\"Script at specified location: scripts/start failed with exit code 1\",\"log\":\"LifecycleEvent - AfterInstall\\nScript - scripts/start\\n[stderr]Error: JAVA_HOME is not defined correctly.\\n[stderr] We cannot execute /usr/lib/jvm/jre/bin/java\\n\"}"}
echo $JAVA_HOME gives
/usr/java/jdk1.8.0_45/jre
Have also tried setting JAVA_HOME to
/usr/java/jdk1.8.0_45
When i try mvn clean install directly in the workspace it was able to pickup the Java correctly. Any idea what went wrong in code deploy?
hooks:
BeforeInstall:
- location: scripts/pre_processing
AfterInstall:
- location: scripts/start

Codedeploy seems works fine, it just run whatever script you gave.
This could be a problem of JAVA_HOME not accessible by current running user.
If you don't specify the runas parameter inside the appSpec, the scripts will run under root privilege by default(since the host agent starts with root privilege).
If this is the case, the possible workaround is either make JAVA_HOME accessible by root, or specify runas inside the appSpec for the AfterInstall script.

Related

Java Home not define (wso2ei-6.4.0 installation)

I am trying to install wso2ei-6.4.0, but it will not run due to the following error messages. I am running a RPi with Debian
Error: JAVA_HOME is not defined correctly.
CARBON cannot execute java
I have executed Java -verison and have the following return
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)
I know the java directory, using Java -which
/usr/bin/java
How do I run Java from any of the directory to execute the installation of wso2ei-6.4.0?
After some time and reading, I managed to add the following into ~/.bashrc:
export JAVA_HOME="/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt"
export PATH=$PATH:$JAVA_HOME/bin
Note the arm32 directory for the jdk
Try this (as root user):
export JAVA_HOME=/usr/bin/java
Does this solve your issue?

Java not recognized on PowerShell

I'm using PowerShell on Windows 2012 server, and I deleted all the java commands from System32, reinstalled jdk, set JAVA_HOME and Path to point at the new installation. And I still get the following error:
java : The term 'java' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ java
+ ~~~~
+ CategoryInfo : ObjectNotFound: (java:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I deleted all the java commands from System32
This is why Windows can't find java.exe. The default JRE installation puts Java into your System32 directory, which is where CMD and Powershell usually find it.
You can fix this for your system by running the following from an admin shell. This creates a copy of java.exe in your Windows directory. (You can also probably get away with a soft link)
fsutil hardlink create (join-path $env:SystemRoot 'java.exe') (join-path $env:JAVA_HOME 'bin\java.exe')
If you don't want to modify your Windows directory (or can't), you can always set an alias to use in your Powershell session.
Set-Alias -Name java -Value (Join-Path $env:JAVA_HOME 'bin\java.exe')
Run that line in your current session and running java from the command line should work correctly. Add it to your $PROFILE if you want it to work from all future Powershell sessions.
PATH needs to point at the bin/ directory within the JDK/JRE installation
JAVA_HOME needs to point to the top level directory of the JDK/JRE
I suspect you're setting PATH to be the JDK/JRE folder which doesn't contain the java executable, as it's in the bin/ subdirectory...
1) My default JAVA_HOME is:
echo %JAVA_HOME%
D:\Program Files\Java\jdk1.7.0_25
<= The installer automagically configures this when you install a JRE
2) My default %PATH% does not include any Java
3) I'm able to run (but not compile) Java from a Windows command prompt:
java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
4) I'm also able to do exactly the same from inside Powershell (or from a .ps1 Powershell script):
PS D:\temp> java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Error: could not find libjava.so, Error: could not find Java 2 Runtime Environment

I uninstalled java j2sdk1.4.2_12 java on my Linux Server and Install jdk1.6.0_21,
but when I am trying to run any script I am getting following Error
Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment.
I already set classPath and Path like :
In vi ~/.bashrc
export JAVA_HOME=/home/java/jdk1.6.0_21/
export PATH=$PATH:/home/java/jdk1.6.0_21/bin
export set CLASSPATH=/usr/java/j2sdk1.4.2_12/lib/mysql-connector-java-5.1.6-bin.jar: /home/java/jdk1.6.0_21/jre/lib:/root/mis/mod:$CLASSPATH
ulimit -c unlimited
IN vi ~/.bash_profile
JAVA_HOME=/home/java/jdk1.6.0_21/
PATH=$PATH:$HOME/bin:$HOME/mis/mod:
PATH=/home/java/jdk1.6.0_21/bin:$PATH
CLASSPATH=$CLASSPATH:/home/java/jdk1.6.0_21/lib:.:
export JAVA_HOME
export PATH
export CLASSPATH
unset USERNAME
When I run following Commands
which java
/home/java/jdk1.6.0_21/bin/java
java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)
I am not getting where is the issue.
Can Any one help me ?
I encounter this issue before. It turns out there are 2 javac program sitting on my machine.
They are in /usr/bin/javac and /bin/javac. My system used the /bin/javac one. The right path for me is /usr/bin/javac. Removing /bin/javac helped
I faced the same issue, and it disppeared by just shutting down the CentOS VM and then starting again. Then type in javac command again to check.

error in setting java home environment variables ubuntu

i am new to ubuntu .initially i installed java in Ubuntu.
But i haven't set any envionment variables
After that installed maven build tool to build java package.when i compiled with build tool it shows some error says generic supports after 1.3 packages.
so i realize it JDK runs with 1.3. so i need set java environment variables for latest version
so in my Terminal java -version shows
beeshma#ubuntu:~$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
and i set java environment variables in through below steps
[https://askubuntu.com/questions/277806/how-to-set-java-home][1]
sudo gedit ~/.bashrc
Now go to end of file and add the following lines:
export JAVA_HOME=/path/to/jdk/folder
#usually /usr/java/jdk or /usr/lib/java/jdk
export PATH=$PATH:$JAVA_HOME/bin
Now in terminal type:
sudo source ~/.bashrc
This will make it appear on every terminal if open.
Now you can cross check it by typing following line in terminal
$echo $PATH
/usr/java/jdk1.7.0_45//bin:/home/beeshma/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/java/jdk1.7.0_45//bin
What my question when i execute mvn --help
Fallowing error is coming
beeshma#ubuntu:~$ mvn -version
Error: JAVA_HOME is not defined correctly.
**We cannot execute /usr/java/jdk1.7.0_45//bin/java**
Try changing your export to:
export JAVA_HOME=$(/usr/java/jdk1.7.0_45)
Two things:
Try if /usr/java/jdk1.7.0_45//bin/java is indeed present.
See if the beeshma user has the permissions to 'execute' java.
Bonus: remove the trailing / in your JAVA_HOME value.
You can install the JDK with the following command:
$sudo apt install default-jdk
The above command also sets the java environment variable automatically

Java runtime not found in OSX 10.9.1 while running solR

I want to run solR in mac OSX 10.9.1. So I installed JRE latest version. Then, I downloaded solR and expanded the folder. But when I try to run this jar file in example folder, I get this msg "no java runtime present", mentioned below.
Do I need to add JAVA_HOME env variable like we do in windows? If so, please tell me how.
Ananyas-MacBook-Pro:~ ananya$ /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build
1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
Ananyas-MacBook-Pro:~ ananya$ cd /Users/ananya/Desktop/VT\ study/solr-4.6.1/example
Ananyas-MacBook-Pro:example ananya$ java -jar start.jar
No Java runtime present, requesting install.
Ananyas-MacBook-Pro:example ananya$
Thanks.
"Do I need to add JAVA_HOME env variable like we do in windows?"
Test to see if/where Java is on your path in a terminal:
echo $JAVA_HOME
If the path to Java is wrong or missing you can add and Environmental Variable to ~/.bash_profile like so
JAVA_HOME=/usr/bin/java #or whatever your path is
export PATH=$PATH:$JAVA_HOME/bin/
You can open ~/.bash_profile in a terminal with nano
nano ~/.bash_profile.
Nano hint: writeout means save.
You'll need to reopen your terminal to load the new path. Or, reload it with the source command.
source ~/.bash_profile
Alternatively, if you like saving keystrokes you can type
. ~/.bash_profile

Categories

Resources