I have a Server implemented in Java named Provider, and linux script to start it.
#!/bin/bash
echo "Provider"
$JAVA_HOME/bin/java -cp /tmp Provider&
$JAVA_HOME/bin/java -version
rm /tmp/pid
echo "$!"> /tmp/pid
echo "Provider-finish"
exit 0
When I want to execute the following script at different machine (machine2)
root#machine1:/tmp# ssh machine2/tmp/runScript.sh
Provider
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)
Provider-finish
Waiting for connection
The problem is that after running above script, it does not return console, it hang-up though Provider gets started.
I have analized similar concepts like Glassfish domain starting. by executing
ssh machine2 asadmin start-domain
it returns console without any problem so I can get execution status "$?"
I think that the problem is that the remote sshd won't close the ssh session because there is still a java process running in the background that might try to write output.
Try redirecting the background processes stdout and stderr to "/dev/null"; e.g.
$JAVA_HOME/bin/java -cp /tmp Provider > /dev/null 2>&1 &
Related
I start and attach a docker container, but nothing working after setting JDK.
Docker container didn’t work after the command.
ken#namenode:~$ docker start peaceful_babbage
peaceful_babbage
ken#namenode:~$ docker attach peaceful_babbage
root#1477050f192a:/#
root#1477050f192a:/# java -version
bash: java: command not found
root#1477050f192a:/# source /etc/profile
root#1477050f192a:/# echo $PATH
/usr/lib/jdk1.7.0_60/bin:/usr/lib/jdk1.7.0_60/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
root#1477050f192a:/# java -version
java version "1.7.0_60"
Java™ SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot™ 64-Bit Server VM (build 24.60-b09, mixed mode)
root#1477050f192a:/#
root#1477050f192a:/# java
Usage: java [-options] class [args…]
(to execute a class)
or java [-options] -jar jarfile [args…]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the “server” VM
The default VM is server.
...
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
^C
At this moment, I can’t do anything with this container. can’t kill the Java process either. Who can help me with this?
You can simply stop the container from the host :
docker stop peaceful_babbage
I have been trying to setup elasticsearch in windows7 machine by following https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html
I was able to download, unzip but when running ./elasticsearch, I get the below error,
Error: Could not find or load main class
org.elasticsearch.tools.JavaVersionChecker
Elasticsearch requires at least Java 8 but your Java version from C:\Program
Files\Java\jdk1.8.0_131/bin/java does not meet this requirement
I have verified Java versions installed and they look fine,
$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
$ javac -version
javac 1.8.0_131
Can someone point out where I am wrong ?
In run Elasticsearch in Windows, you should run with elasticsearch.bat not ./elasticsearch directly:
And now we are ready to start our node and single cluster (Windows users should run the elasticsearch.bat file):
Seems like you don't have right permissions. Try to set them to 774 and check again:
sudo chmod 774 -R elasticsearch-6.3.2/
thanks to read my question.
I want to use rjb, twkorean gem. These are successfully installed
but I got error........
Completed 500 Internal Server Error in 19ms
RuntimeError (can't create Java VM):
I had installed java-7-oracle
$ echo $JAVA_HOME
/usr/lib/jvm/java-7-oracle
$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$ ps aux | grep jvm
newstru+ 26483 0.0 0.0 11740 932 pts/0 R+ 18:08 0:00 grep --color=auto jvm
Following code is my production envirnment (ubuntu 16.04).
I don't understand this error. I have no idea.
please, tell me any idea.
You should check and post some logs to get more information about the problem. It could have many root causes:
The tool you are trying to use does not have permissions to execute
java
The tool you are using cannot find the java executable. According to http://rjb.rubyforge.org/ you could try to set LD_LIBRARY_PATH to contain your $JAVA_HOME/bin folder.
In general, you should maybe try searching for (and reading) documentation about your tools first before posting to SO, and when posting, follow some basic rules: https://stackoverflow.com/tour
I am writing an installation procedure in Python 3.4.3 that will install Java and MySQL if the required versions from the program it is installing are not installed (with user permission of course). Currently I'm doing this only for Windows. Other operating systems will come later. I'm using the commands: java -version and mysql --version to check if they have been installed properly (i.e. they are on the PATH environment). I had the problem that the current command prompt wouldn't know about the updated PATH environment after installing Java and MySQL. Because of this I implemented this code:
import subprocess
output = subprocess.Popen("start cmd.exe /C \"java -version\ ",
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
This solved that problem. However, I want to check the output of these commands so I can check to make sure Java and MySQL were installed correctly and that the correct versions are being used. When I try to check stdout or stderr, they are empty. I believe this is because those outputs are of "start" and not of java -version. Is there a way to redirect the output of java -version to the original command prompt? OR is there a way to access the output of the command prompt opened up by "start"? I have tried redirecting stderr to stdout (i.e. 2>&1) but I didn't really think that would help.
import subprocess
output = subprocess.check_output(["java","-version"])
print(output)
Output:
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
I'm getting the error to run the script "ec2-describe-regions"
$ec2-describe-regions
/usr/local/ec2/ec2-api-tools-1.6.14.1/bin/ec2-cmd: line 62: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java/bin/java: Not a directory
Before it, I did followings:
Open a terminal on my personal computer.
Install Java.
Create security credentials (an X.509 certificate and private key).
Set up a few environment variables.
Run my first command.
Here is the information I did:
$which java
/usr/bin/java
$echo $EC2_HOME
/usr/local/ec2/ec2-api-tools-1.6.14.1
$echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
$java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
Try the following:
mv /usr/bin/java /usr/bin/java.orig
ln -s /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java /usr/bin/java
You may have two or more java instances on your server. Make sure you use the same java executable where your JAVA_HOME points to.
This command uses the old CLI tools, i'd recommend you use the new, unified and greatly improved CLI:
https://aws.amazon.com/cli/