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
7/4/2022 6:58:07 AMPardha Saradhi
11 AnswersNew Answer
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.
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
Yes. They do need JRE. That's why Java sucks.
Either way, client software needs to be installed anyway. You can just bundle the JRE with the software. There are ways to do that.
Mustafa A Thank you
Mustafa A if we need JRE, How real time projects work? Not every client have JRE, right?
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
Mustafa A so for web developing, java won't help?