How do i remotely shutdown client/s system from server end ?
Also, how do i run any command on client/s command prompt ?
How do i send the line of codes to the client end from the server side ?
I've used ArrayList to send messages across the client earlier.
I guess this is what you are looking for:
Shutting down a computer
Already been asked on here :)
For shutting down a computer remotely use:
shutdown /s /m <Computer_Name>
Link to that post aswell: Shutdown Remote Computer in Java- Cannot initiate shutdown but no errors
Related
I'm looking for a way to deploy my Play-Framework-1.0 application on the port 80.
So first I made the zip file with 'dist' command, then I unzipped it.
When I run the command to lauch the application (play-java-1.0-SNAPSHOT/bin/play-java -Dhttp.port=80 -Dhttp.adresse=127.0.0.1), I get this error :
[error] p.c.s.NettyServer - Failed to listen for HTTP on /0.0.0.0:80!
Oops, cannot start the server.
play.core.server.ServerListenException: Failed to listen for HTTP on /0.0.0.0:80!
at play.core.server.NettyServer.play$core$server$NettyServer$$bindChannel(NettyServer.scala:215)
at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:203)
at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:203)
at scala.Option.map(Option.scala:146)
at play.core.server.NettyServer.<init>(NettyServer.scala:203)
at play.core.server.NettyServerProvider.createServer(NettyServer.scala:266)
at play.core.server.NettyServerProvider.createServer(NettyServer.scala:265)
at play.core.server.ServerProvider$class.createServer(ServerProvider.scala:25)
at play.core.server.NettyServerProvider.createServer(NettyServer.scala:265)
at play.core.server.ProdServerStart$.start(ProdServerStart.scala:53)
at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
at play.core.server.ProdServerStart.main(ProdServerStart.scala)
Moreover, in the real server, Apache has been installed. So I wonder, whether that will be a problem.
Thanks!
Optionally, also remember that on most systems, running processes on ports lower than 8000 is disabled in default, in such case you need to allow it, i.e. on Unix servers, just using sudo command(prefix).
If you are using a Linux server, you can try 'fuser 80/tcp' to see whether another process is already running on that port (80). If so (there's showing a process-id, when you enter the command), you cannot use the same port for 2 processes.
Either, you have to start the Play-app in a different port or you can kill the already running process by 'sudo fuser -k 80/tcp' and start the Play-app on the same port (80).
It's not possible to have two processes running on the same host listening on the same port.
However, you could run you Play application on different port, e.g. 8080 and set up Apache as a reverse proxy (Nginx would do too, but you mentioned that you already have Apache running on the server) to forward requests to your Play application.
Example guide how to do that:
https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension
I need to debug a web application for Tomcat6 in IntelliJ IDEA.
When I try to run my web application, I get two errors:
Address localhost:1099 is already in use
Unable to open debugger port: java.net.SocketException
Launching the Apache Tomcat 6 service manually works fine.
What should I do in order to be able to debug web applications in Apache Tomcat 6 from Intellij IDEA?
Following the below steps work:-
Open command prompt and type the command netstat -ano
You will see a list of active TCP connections with PID as the last column
See the second column listing the local addresses and find the one using port 1099 from it and you'll get its PID
Now open your Task Manager, click the Process tab and get the PID column to display [either by right clicking on the heading row and selecting PID OR click View, and then click Select Columns and select PID.]
Now find the PID we got from Step3 and end the process.
Now you are good to go :)
I face this issue all the time. Here's how to fix it
LINUX
Open a terminal instance.
fuser 1099/tcp
This should return you a process ID.
1099/tcp: 31596
where 31596 is the process ID. Now you can either use the process ID to kill it or just bash the following -
fuser -k 1099/tcp
WINDOWS
Open a command prompt instance.
netstat -aon | find "1099"
This will return you an instance of the process.
output:
TCP 0.0.0.0:1099 0.0.0.0:0 LISTENING 15776
Here 15776 is the process ID. To kill this, enter -
taskkill /F /PID 15776
Cheers!
You can change the JMX port (1099 per default) in the Run/Debug Configuration dialog. Just try a different port number (i.e. 9099).
If you had the web application up and running before, there may be an old debug server that did not close down properly running in the background. See this post about how to find what process that uses port 1099. If it proves to be a java process, kill it.
How can you find out which process is listening on a port on Windows?
(If you use the GUI sw suggested in the link above, you may kill the process(es) by marking all java processes that uses port 1099, right click and press "End Process...")
As said before, there's an old debug server running in the background.
My solution was to close the Java process that was left open from the Windows Task Manager.
Please verify that you can close this process before doing so!
Change your http port to 8080(default for tomcat) and debug port to something that is not being used currently by any processes. You can use anything that is upwards of 1024, but since you are getting an error on 1099, try something that is greater that 6000.
Debugger setting can be found here
There might be other program or server running at the background. First close other server running in the background and then restart your server.
I found this answer helpful:
How can you find out which process is listening on a port on Windows?
I opened the resource monitor and looked for what was using the ports. Then opened task manager and ended those processes
What worked for me was. I assumed I would need to have the "Apache Tomcat" service running under "Services" [Windows + R >> services.msc]
I went and stopped the Tomcat service here. Then I came to my Java application and ran it in Intellij, which allowed me to run it.
Hope this helps!
Just close all other unnecessary servers while using InteliJ.
I stopped my WAMP in order to remove this error "Port is already in use".
if we are to have an RMI server application which runs permanently via autosys and then shuts down for a few hours over night, how to we send the shutdown message if the application was started from the command line.
for example, we start the jar using java -jar server.jar and now the application is running. if it contained a applicationClose() method how could we call it - we could parse the message from the client but of course this is undesirable?
It is perfectly acceptable to make a closedown request method available, that returns OK and then calls System.exit().
You might want to protect it with some sort of required credentials before it can be called, but other than that there is no reason why you can't.
The other option is for the process to have another TCP port open with your own protocol for shutting down, or to have a JMX extension installed to remotely shut down the service.
i encountered a problem using the apache commons-net telnet api, and hope you can help me with it.
i am connecting to a remote unix server via telnet and running a script , that at some point run an .sh file. that file open a server that needs to continue running even after the telnet connection to the client is closed. the problem is that when i close the client connection the process stops. i think that when the connection is lost there is no reference to the running process and the os is killing it but im not sure.
if that is the case i understand that if a could open the server process as a deamon process the problem will be resolve.
maybe there are other ways to do it...
can someone help me to solve this thing?
thank
moshe ben noun
A combination of nohup and running the process in the background using & should do what you are looking for.
http://www.livefirelabs.com/unix_tip_trick_shell_script/june_2003/06022003.htm
I'm unable to login to an HPUX host using telnet when the telnet process is created by a Java program.
When I telnet to the HPUX host from the command line (from bash), I am able to login and use the session.
When I spawn the telnet process from Java, something strange happens. I am prompted for the username and submit it. I also get the prompt for the password. But for some reason the telnet server does not wait for the password; it quits the session before it is sent.
Looking at the exchange in wireshark, I see that as soon as the telnet client sends an ACK for the password prompt, the server sends a FIN packet, terminating the initializing session.
One of the differences I can see in the handshaking leading up to the password prompt is that the server asks for the terminal speed. When running telnet from the command line, the terminal speed it sends is 38400,38400. When running telnet from Java, the terminal speed is 0,0.
Looking at the source code of a telnet client, I found that one source of the "terminal speed" sent by the telnet client is the output of the cfgetospeed()/cfgetispeed() APIs. According to this, a meaning of 0 baud rate is "hang up", which is how it looks like the HPUX telnetd process is interpreting it.
I'm running from Linux Fedora Core 6.
I suspect that the $TERM environment variable is indirectly used to determine the speed, and is not set when spawning it from Java.
If that's not it, you could also try launching telnet through bash, i.e. start bash from Java and send it the telnet command line. That should provide exactly the same environment as when you launch it manually.