Websphere Application Server 8.5 Java 7 questions - java

I have the following questions on WAS 8.5 installation:
Can Java 7 be installed outside {or}c:\IBM\Websphere\Appserver
Can the Java 7 name be other than Java1.7_64?
Also how to get the info. using any bat/sh file from IBM
Thanks in advance

No to both: there is no way to change the Java install directory.
To determine the configured JDK, source setupCmdLine and use the JAVA_HOME variable. For example, on UNIX:
. /path/to/profile/setupCmdLine.sh
echo $JAVA_HOME
...and on Windows:
C:\path\to\profile\bin\setupCmdLine.bat
echo %JAVA_HOME%
If you need to automate discovery, you might write a temporary batch file with the following contents, execute it (e.g., using ProcessBuilder), and then parse the resulting output:
#echo off
call "C:\path\to\profile\bin\setupCmdLine.bat"
echo JAVA_HOME=%JAVA_HOME%

Related

JMeter test cannot start on the TFS agent

I'm trying to run the JMeter test using the TFS build definition. I've created the required task to run the JMeter test (command-line task), but I'm getting the following error:
Not able to find Java executable or version. Please check your Java installation.
errorlevel=2
Press any key to continue . . .
I've checked the java version on the agent:
I've mentioned the following system variables:
JMETER_HOME as C:\Performance Tests\apache-jmeter-3.2
JRE_HOME as "C:\Program Files\Java\jre1.8.0_231"
to the Path variable was added C:\Performance Tests\apache-jmeter-3.2\bin;C:\Program Files\Java\jre1.8.0_231\bin
When I try to run the JMeter on the agents I don't get any error:
Windows Server 2012 R2 64 bit is installed on the agent.
On another agent (which is the same and has similar configs) the test is running with no issues.
Could someone tell me what is the reason for the issue? Thank you in advance 😊
Looking into jmeter.bat source:
for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
rem #echo Debug Output: %%g
set JAVAVER=%%g
)
if not defined JAVAVER (
#echo Not able to find Java executable or version. Please check your Java installation.
set ERRORLEVEL=2
goto pause
)
it appears that the JMeter startup script is not capable of parsing the output of java -version command in order to determine Java runtime version
So make sure to have "bin" folder of your JRE or JDK installation added to your operating system PATH environment variable
In order to have 100% confidence that it will work add this line to the beginning of your jmeter.bat script:
set PATH="C:\Program Files\Java\jre1.8.0_231\bin";%PATH%
also be aware that according to 9 Easy Solutions for a JMeter Load Test “Out of Memory” Failure article you should always be using the latest version of JMeter so consider upgrading to JMeter 5.2.1 (or whatever is the latest stable version available at JMeter Downloads page) on next available opportunity

Eclipse unable to locate Java in Ubuntu

While I am trying to install the Payara server on my Ubuntu machine after putting the path of the Payara/glassfish server when I try to put the java location whatever i give as path is considered as error. I use Oracle java 10 and as I put the value "/usr/lib/java/jdk-10.0.1/" it says its not a jdk. Path for Java 10 has been properly set in ~/.bashrc as
export JAVA_HOME=/usr/lib/java/jdk-10.0.1/
export PATH="$PATH:JAVA_HOME/bin"
Why is this behaving in this way? Can anybody suggest me a way out.
try export PATH=$PATH:${JAVA_HOME}/bin
Your shell is interpreting JAVA_HOME as string, you forgot a $ before JAVA_HOME in the export PATH line to make it interpret as a variable.

Use specific jvm installation when call java application from php code

I have two installations of JDK on my account and I do not have root access to change the default one which is "usr/bin/java" to specific one /home/username/jdk/bin/java"
I tried to do the following in my php code:
$JAVA_HOME = "/home/username/jdk";
$PATH = "$JAVA_HOME/bin:".getenv('PATH');
putenv("JAVA_HOME=$JAVA_HOME");
But when I execute the following just below above mentioned lines:
which java
I got /usr/bin/java
Any idea please how to make it works? The java application I want to run from php code does not work on the default one.
Thanks
If feasible, qualify the java command, e.g. /home/username/jdk/bin/java, when running your Java program.
This way you can even use multiple different JVM's in different places of your PHP code.
Note: I know that using qualified access like this works on Windows, even if JAVA_HOME points to a different installation. I'm assuming the same is true for Linux.
Try to set JAVA_HOME as temporary parameter for the context of your application, i.e. right before the command (see the second command, the others just show that the variable is only set for that one command):
> java -version
java version "1.8.0"
> JAVA_HOME=~/jdk1.7.0_51.jdk/ java -version
java version "1.7.0_51"
> java -version
java version "1.8.0"
In PHP:
exec("JAVA_HOME=~/jdk1.7.0_51.jdk/ java yourapplication");
Source: Bash Reference Manual – Environment
The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described in Shell Parameters. These assignment statements affect only the environment seen by that command.
To see the differences in a browser I tested with this ugly PHP snippet:
<?php
echo "<pre>" . shell_exec('java -version 2>&1') . "</pre>";
echo "<pre>" . shell_exec('JAVA_HOME=~/jdk1.7.0_51.jdk java -version 2>&1') . "</pre>";
echo "<pre>" . shell_exec('~/jdk1.7.0_51.jdk/bin/java -version 2>&1') . "</pre>";
?>
You may also use a specific version of the java executable by explicitly using it to run your app:
shell_exec("~/jdk1.7.0_51.jdk/bin/java -version");

Neo4J Server Installation Linux AWS Centos OS -- service user cannot find java

I have downloaded Neo4J enterprise from the Neo site and have untar'd it under /opt
I have successfully downloaded and installed the Java 7 Server edition from the Oracle web site. Note after indicating I want a server JRE, Oracle downloads this : jdk1.7.0_51
I have untar'd both under /opt giving me /opt/neo4j-2.0.0 and /opt/jdk1.7.0_51
I have successfully installed Neo4J 2.O on AWS with Centos Linux, such that it should run as a Service under a service account. To do this I used the Neo install command. The command ran successfully
I can successfully start Neo4J as myself. After editing my ~/.bash_profile to define JAVA_HOME and exporting.
export JAVA_HOME="/opt/jdk1.7.0_51/"
export NEO4J_HOME="/opt/neo4j-2.0.0"
export PATH=$JAVA_HOME/bin:$NEO4J_HOME:$PATH
Apply
source ~/.bash_profile
cd /$NEO$J_HOME
bin/neo4j start
Works just fine.
However, we are not able to successfully get Neo to start as a service
sudo service neo4j-service start
which: no java in (/sbin:/usr/sbin:/bin:/usr/bin)
ERROR: Unable to find java. (Cannot execute )
* Please use Oracle(R) Java(TM) 7 to run Neo4j Server. Download "Java Platform (JDK) 7" from:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
* Please see http://docs.neo4j.org/ for Neo4j Server installation instructions.
If I echo $JAVA_HOME it returns as expected
If I echo $PATH it returns as expected
by as expected we can see java on the path.
If I simply type java -version before I run sudo service neo4j-service start
the response shows the java version.
A bit of background: the Linux service command is not available unless I first run a special script per our normal it policies. However, the script clobbers the exports that I would otherwise use.
Accordingly the command
service neo4j-service start
returns
-bash: neo4j-service: command not found
indicating that the 'service' command cannot be found
So sudo is required in our environment to execute the service command
We have tried simply placing jdk1.7.0_51 under /sbin/jdk1.7.0_51 that does not work. We have also tried extracting the jre folder from jdk1.7.0_51 and placing it under /sbin/jre
Also tried creating a java.sh file under /etc/profile.d/
Still no success.
So the simple question....
Where is Neo4J 2.0.0 looking for Java when running as a service? Is it using the environment variable JAVA_HOME, or is it looking in one of the following locations as the Neo4J server error message would seem to indicate? "no java in (/sbin:/usr/sbin:/bin:/usr/bin)"
Under my installation configuration the neo4j service is intended to run under the account neo4jservice. Is this as simple as making sure JAVA_HOME is available to the neo4jservice accound? Why the error message "no java in (/sbin:/usr/sbin:/bin:/usr/bin)"?
Thanks in advance
I ran a test on my solaris and Linux Mint install and this seems to work for me
Perhaps it's not elegant, but it will get you going. Just drop the sudo part for your startup script.
sudo NEO4J_HOME="/opt/neo4j" JAVA_HOME="/usr/java" /opt/neo4j/bin/neo4j start
Obviously, modify the environment variables to your situation:
JAVA_HOME="/opt/jdk1.7.0_51/" NEO4J_HOME="/opt/neo4j-2.0.0" service neo4j-service start
Not quite the answer I was hoping for... as the answer seems to disregard this part of the original POST: "So sudo is required in our environment to execute the service command"
What does seem to work is modifying the neo4j-service script to include the exports.
neo4j-service is found at /etc/init.d

my tomcat uses wrong JAVA_HOME or JRE_HOME

I'm new to Tomcat. their is something wrong about Tomcat 7 on my ubuntu 10.10.
when I start Tomcat like this
llchli#llchli-virtual-machine:/usr/local/apache-tomcat-7.0.47/bin$ ./catalina.sh run
Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.47
Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.47
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.47/temp
Using JRE_HOME: /usr/local/jdk1.7.0_45
Using CLASSPATH: /usr/local/apache-tomcat-7.0.47/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.47/bin/tomcat-juli.jar
although cannot start Tomcat this way, it echos Using JRE_Home /usr/local/jdk1.7.0_45, which is the correct JAVA_HOME or JRE_HOME on my computer.
but when I start Tomcat with sudo like this
llchli#llchli-virtual-machine:/usr/local/apache-tomcat-7.0.47/bin$ sudo ./catalina.sh start
[sudo] password for llchli:
Using CATALINA_BASE: /usr/local/apache-tomcat-7.0.47
Using CATALINA_HOME: /usr/local/apache-tomcat-7.0.47
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.47/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/apache-tomcat-7.0.47/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.47/bin/tomcat-juli.jar
it echos Using JRE_HOME: /usr,which is not the correct JAVA_HOME or JRE_HOME on my computer. But it start Tomcat correctly.
my /etc/environment is
llchli#llchli-virtual-machine:/usr/local/apache-tomcat-7.0.47/bin$ sudo cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/jdk1.7.0_45/bin"
LANGUAGE="en"
JAVA_HOME="/usr/local/jdk1.7.0_45"
CLASSPATH="$CLASSPATH:$JAVA_HOME/lib"
CATALINA_HOME="/usr/local/apache-tomcat-7.0.47"
I'm a bit puzzled about this.And when I use daemon.sh like this, it generate errors.
llchli#llchli-virtual-machine:/usr/local/apache-tomcat-7.0.47/bin$ sudo ./daemon.sh run
Cannot find any VM in Java Home /usr
Cannot find any VM in Java Home /usr
Cannot locate JVM library file
Service exit with a return value of 1
It echos cannot find any VM in Java Home /usr. I'm so confused.
Any helps and advise will appreciate.
Thanks in advance.
It sounds like "sudo" is not passing your JAVA_HOME and JAVA_PATH through to the child process.
When you run a command using "sudo" the environment variables are set according to what the sudoers file says. My reading of the "sudoers" manual entry is that the default is to NOT pass variables through. But according to the "sudo" manual entry, there is a command syntax variation that allows you to pass environment variables using "VAR=value" ...
I suggest that you read the manual entries for "sudo" and "sudoers" carefully, and then read your system's "/etc/sudoers" file to understand how it is behaving.
Having said that, launching services from the command line using "sudo" is not a good idea, especially if you are talking about "production" services. And you are generally better off using the service wrappers provided by your distro's packaging, rather than a non-packaged install from the "upstream" project.
Sudo resets the environment variables. When you run sudo, JRE_HOME is reset to its default (probably null) and Tomcat will assume its own default (/usr). You can run sudo with the -E switch to preserve the environment.
Are you sure, you must run the script as root? I have no idea how to set up Tomcat, but it is usually a good practice to run servers as a dedicated user instead of as root.
As i already state in a comment, i strongly suggest you to use the package system to install software, it it's available in the repository. (plus there are ppa's for nearly everything). That way you will keep your system tidy and you won't have worry about things not working (usually).
My suggestion is to remove your current manual install and install the tomcat7 package.
apt-get install tomcat7
For further configuration, use the file /etc/default/tomcat7. To start/stop/restart use the command service tomcat7 {start|stop|restart}.
Using the package tomcat7 the tomcat instance will run as it's own user, and not as root, and that's good, since a service should not run as a user with full privileges.
I am aware that i am actually not answering your question with the environment variables. But using the suggested way, you will not face that problem to begin with.
it is all said, it means adding to /etc/sudoers a line with:
Defaults env_keep += "JAVA_HOME JRE_HOME"

Categories

Resources