Hosting Java Server on LInux Virtual Machine - java

I am trying to host a Java server on Linux (Ubuntu 13) virtual machine on VirtualBox. I have to connect a client locally to the server via sockets. I am having trouble setting up the ip address and port for the client to find the server socket on the virtual machine.

you should get the IP address on the VM
then ping the IP address from your CMD, if it's ok, then trying to run Java program, if not, you should focus on the VM configuration.
About your code, you can always run a Java socket server just on Windows and using a Java client to connect, after successfully test the code. You can launch the server code in VM.

Related

How to connect remotely via tcp to the h2 database?

I am trying to start H2 in server mode to connect an application from another computer. But no matter how hard I have tried, I have not succeeded.
I have seen the documentation and to start the server from the command line is executed:
java -cp h2-2.1.214.jar org.h2.tools.Server -tcpAllowOthers
output:
TCP server running at tcp://127.0.1.1:9092 (others can connect)
PG server running at pg://127.0.1.1:5435 (only local connections)
Web Console server running at https://127.0.1.1:8082 (others can connect)
now from the other pc, as I understand I must execute the connection in the following way:
jdbc:h2:tcp://[server][:port]/[path]/[databaseName]
then it should be:
jdbc:h2:tcp://127.0.1.1:9092/home/mateo/database
But I have read that 127.0.1.1 only works locally. I have also noticed that when I open H2 Console in the examples I have seen, the machine's ip appears, that is to say: 192.168.X.
What am I doing wrong?
(Update)
I am currently using Linux.
I have launched the server from Windows and managed to connect it from Linux successfully following the above steps. But, I still don't understand why it doesn't work in Linux, in Windows it loads the server with the IP address of the machine. It makes me think that I have to do some additional configuration for Linux.
server running
You need to replace local IP address in your JDBC URL with real non-local IP address of your server (jdbc:h2:tcp://127.0.1.1:9092/*** -> jdbc:h2:tcp://192.168.1.4:9092/***, for example). H2 listens all network interfaces of the host, it doesn't matter which address was reported in “runnig at …” message.
You also may need to protect ports 8082 and 9092 from connections from untrusted systems if you have them in your internal network and from connections from external network (make sure your router or whatever you have doesn't redirect connections to the host with database server).

Jprofiler Connection error from GUI to remote server

As I am testing Jprofiler, I was able to connect from my local GUI to remote server for couple of days. Now suddenly I am getting connection error. Nothing is changed on my local machine or remote machine. Java-version and path is correct for both local and remote server. The port is listening to no other application.
error is
"Either an old version of the native library is used or another application is listening on port 8849. Please check your PATH environment variable and your port configuration"

ServerSocket in Java application running in Azure Virtual Machine with Ubuntu?

I've created an Ubuntu Virtual Machine in Microsoft Azure and uploaded a Java application which uses a java.net.ServerSocket to handle incoming messages I send - with java.net.Socket - to port 20000. This application works perfectly in any machines, but it can't receive any connections when running in Azure VM.
I realized that the VM won't answer for pings and traceroutes, but I can connect to it using SSH (PuTTY) and also send files using PSCP. I've already configured endpoints on Azure - with the public and private ports (20000). I also tried to disable firewalls on VM, but never successfully. VM isn't reachable.
What more can I try? Thanks in advance.

Find LAN Connection behind VPN using signed java applet?

I am able to run ipconfig /all on the client machine using signed java applet, how to find LAN Connection ip which initiated VPN Connection on client machine as there can be multiple LAN,WI-FI, Virtual connections ?
You cannot do such things with the standard Java API. You will have to connect to native code (either the command line or some C/C++ library using JNI) from your Java code.

Testing a client/server Java application on a virtual machine using VirtualBox

I'm testing a client-server based Java application where a specific scenario involves having both the client and server running on the same host (i.e., the client connects to the server running on localhost). This seems to work fine except for when I test this scenario on a virtual machine (running 32bit Windows 7) using VirtualBox.
Note: Everything henceforth is running inside the virtual machine. I start the server and try to connect to it using the client but the connection times out. Surprisingly, I tried connecting to the server using putty and the connection behaved as expected. Both the Java client and putty tried to connect to localhost - the client failed but putty succeeded.
Does anyone have a possible explanation for why this might be happening?
Note: This is not a duplicate of Addressing localhost from a virtualbox virtual machine
How do you connect to the localhost? By connecting to the hostname "localhost"? You could try connecting to the InetAddress returned by getLocalHost()

Categories