I am going to build a desktop software with client-server facility.What are the things i need to do for client-server?
1.Should i make 2 different version of the software?One with database for the server and one for client without database.
2.Or should i have some options in one software inside the code?Like when to install the user will choose client/server option and then the required part will be installed?
Which is the best way?Can anyone give some step by step idea?
Thanks.

Start with a simple version and add features when you get it working.

The client and server will probably be quite different programs, with completely different installation requirements, so I would say "keep them separate". The client will probably just be a single jar file, but the server will be a different jar, plus database etc.
Either way, your installer can still ask the user which to install and do whatever is required. There's no reason why the installer and the application(s) should have the same structure.

Your server program will be installed once/ so distributing a one program with server and client capabilities would be redundant.

Design and distribute your client and server applications seperate.

I have alot of experience with client -> server (and vice versa) operations.

You need to learn how binary works, you also need to learn bitwise operations, for example, writing a 4-byte signed integer (d word) to a buffer:

private byte[] buffer = new byte[4];
	private int bufferOffset;
	
	public void writeDWord(int i) {
		buffer[bufferOffset++] = (byte) (i >> 24);
		buffer[bufferOffset++] = (byte) (i >> 16);
		buffer[bufferOffset++] = (byte) (i >> 8);
		buffer[bufferOffset++] = (byte) i;
	}

Then reading that 4-byte signed integer (d word) from a buffer:

public int readDWord() {
		return ((buffer[bufferOffset++] & 0xff) << 24)
			+ ((buffer[bufferOffset++] & 0xff) << 16)
			+ ((buffer[bufferOffset++] & 0xff) << 8)
			+ (buffer[bufferOffset++] & 0xff);
	}

Depending on the application your making, it'd also be good for you to create a packet sending / receiving system, this makes life easier, and heightens the performance of your application.

Or, you could use an API, such as apache mina.

I'm sorry that I barely answered your question, I just thought this would help you.

I have alot of experience with client -> server (and vice versa) operations.

.....
Or, you could use an API, such as apache mina.

I'm sorry that I barely answered your question, I just thought this would help you.

No no,It is really very helpful for me.Please keep sharing your ideas with me if possible.Thanks a lot.

Be careful about Jaydenn's input. People write client server in Java all the time without ever needing to touch binary or bitwise operations, or feeling any need to use software outside the standard Java SE API.

Don't take my word for this, read the official tutorial - just four pages starting at
http://download.oracle.com/javase/tutorial/networking/sockets/index.html

Please read here:
[snipped blog promotion]

@rsnitch:
This thread is long dead.
If you have a proposal for a good way to do client/server in Java please start your own topic

@JamesCherrill:
Thanks, I'll to do it. My proposal is suitabe for Java too.

In a Java forum you will need to explain why it is better than simply using the existing tried and tested Sockets and ObjectOutput/ObjectInput streams in the standard Java API.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.