Advanced Networking
From jgnash
Contents |
Client / Server networking Intro
jGnash was designed with the intention of supporting multiple users in the same household concurrently. For example, while one spouse may be reconciling the check book, the other could be entering an ATM withdrawal made earlier in the day from different computers.
The reason for designing jGnash in such a manner was to ensure that the application was very robust and built on small standalone components. Instead of creating a huge monolithic system, individual components can be added and removed to display and manipulate the accounting data.
jGnash current implementation consists of a server that can interact with multiple clients. jGnash is not designed to handle a large corporate network. Instead, the focus is on providing advanced client / server capabilities for the home user. As an example, in the near future, it will be possible for a user to run a small client on their cellular phone or PDA that can be used to send home a transaction for the purchase of fuel or groceries at the time the purchase is made instead of collecting a days or weeks worth of receipts and entering them all at once. Theoretically, this can be done today with a wireless client is written, but it does take time. Today's implementation is a full user interface designed to be run across a local network.
Running the jGnash server
Starting a jGnash server is fairly easy. At this time, you must have already started jGnash up as a stand-alone user and created a default file. The server version does not yet create a startup file if one does not exist. The file to work with must be supplied on the command line as follows where filename is the file you have already created.
java -jar jgnash_bin.jar -server filename
An optional means of starting the server is:
java -jar jgnash_bin.jar -server filename -port 5300
The default port is 5300 but can be any available port on your system.
Running the jGnash client
Starting a jGnash network client is also fairly easy. You must have started the server before starting the client and hostname must equal the name of the computer running the server.
java -jar jgnash_bin.jar -client hostname
An optional means of starting the client is:
java -jar jgnash_bin.jar -client hostname -port 5300
The default port is 5300, the same as the server. Be sure to assign it if you specify a port other than the default on the server.
If you would like to try the client and server on the same system, start the client using the following:
java -jar jgnash_bin.jar -client
The hostname will default to localhost
Firewall Considerations
jGnash uses bidirectional communication and will require that -port +1 be open for access as well on the client. For example, if you use the default of 5300, 5301 will have to open as well.
If you use SSH to encrypt communications, be sure that the +1 port is forwarded on the client machine, otherwise communication will break down and jGnash will not function properly.
Example for secure access through SSH
ssh -R 5301:localhost:5301 -L 5300:localhost:5300 user@server.name /path/to/java -jar /path/to/jgnash.jar -server /path/to/file.jgnash.xml
/path/to/java -jar /path/to/jgnash.jar -client localhost
Running a jGnash server as a service
A fun variant of using jGnash in client/server mode is to package the server side inside Java Service Wrapper. This will give it the ability to boot as a service, so that it can load automatically on system startup. Then any client can connect to it as long as the serving machine is on.
To do this,
1. Download the appropriate platform/version of wrapper from the web site.
2. On the wrapper web site there is a description of three different methods to integrate wrapper. Use method one (WrapperSimpleApp).
3. For the section that asks about wrapper.app.parameter, this is what you want:
wrapper.app.parameter.1=jgnash.Main
wrapper.app.parameter.2=-server
wrapper.app.parameter.3=<the full path and name for your account file>
Everything else is just as the directions suggest.
Some problem solving may be avoided by paying attention to these issues:
1. You must have already created a basic accounts file in jGnash in standalone mode before trying this out.
2. The %JAVA_HOME% path may not be set for your system environment. You should ultimately figure out why this isn’t defined and fix it, but if you are getting errors that state your system can't find java, you can test to see if the variable is the problem by replacing it with the full path in the wrapper.conf file.
