+ 2

How to run client Server on client's system without source code?

Hello Guys, I created a Client Server Communication system program in java. It's just a simple program. A single client can send message to server and server can send messages to client. It's working pretty good. Now i want to connect with other system in the LAN. So I shared my Client.java source code to that system and I am running Server.java file in my system. It's working When we do real time projects, it's not a good practice to send that Client.java file to the client, right? Even clients don't understand that too. They don't have JDK in their systems. So can we make this? How to run client in other system connected in LAN ? Is source code sharing the only way? Please answer me Thanks in advance

4th Jul 2022, 6:58 AM
Pardha Saradhi
11 Réponses
+ 4
You can create a executable JAR out of it and send that one instead of the source code. You can then run it on the client computer like any other software. However, you still need JRE on the client device.
4th Jul 2022, 7:17 AM
Mustafa A
Mustafa A - avatar
+ 3
To distribute your client application, normally you would create a package, which contains the compiled bytecode of your client program (your .class files). You don't distribute the .java source files. A package is usually a single file with .jar extension (Java Archive) and it works like a zip archive. It is possible to package your app only, then a Java Runtime (JRE) must also be installed on the client which can execute your program. This kind of package is portable across different system architectures and operating systems. You can also package the JRE together with your app, this will increase the download size, but you have no dependency on the environment, it will be self contained. And it will also only run on a specific OS. It is also possible now to compile your app into native code with GraalVM. Tiny executable size, faster run speed, but again tied to a certain hardware and OS. https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/packaging.html#BABFECGG
4th Jul 2022, 7:49 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Yes. They do need JRE. That's why Java sucks.
4th Jul 2022, 7:23 AM
Mustafa A
Mustafa A - avatar
+ 1
Either way, client software needs to be installed anyway. You can just bundle the JRE with the software. There are ways to do that.
4th Jul 2022, 7:26 AM
Mustafa A
Mustafa A - avatar
+ 1
They actually do download stuff. The browser does in the background. It downloads the html and JavaScript files.
4th Jul 2022, 7:35 AM
Mustafa A
Mustafa A - avatar
+ 1
Mustafa A Thank you
4th Jul 2022, 7:37 AM
Pardha Saradhi
0
Mustafa A if we need JRE, How real time projects work? Not every client have JRE, right?
4th Jul 2022, 7:20 AM
Pardha Saradhi
0
Mustafa A if it is a software, we can bundle with JRE. What about websites? I think users won't download anything to use websites
4th Jul 2022, 7:30 AM
Pardha Saradhi
0
If your server and client are using http, then you can have a web based client using JavaScript. Java won't work.
4th Jul 2022, 7:34 AM
Mustafa A
Mustafa A - avatar
0
Mustafa A so for web developing, java won't help?
4th Jul 2022, 7:39 AM
Pardha Saradhi
0
You can use it for server side, to implement a http server. Then the client can be web based with JavaScript. Look up, "Java spring".
4th Jul 2022, 7:43 AM
Mustafa A
Mustafa A - avatar