Page 1 of 1

[TUTORIAL] How to add new libraries (.jar files)

Posted: 04 Oct 2007, 12:32
by Lapo
In order to add new libraries in the form of jar files to the SmartFoxServer runtime, you need to follow these steps:

1- copy the jar files into the Server/lib/ folder. If the library is made up of several jar files (for example Hibernate) you can create a subfolder (e.g. Server/lib/hibernate) and copy all those files there.

2- you need to tell the JVM to load the jar files by adding them in the classpath.
This can be done in different ways based on your OS and how you're running the server:

-> Running the server as service/daemon

You should open the conf/wrapper.conf file. In the classpath section add a new entry like this:

Code: Select all

wrapper.java.classpath.XX=/path-to-installation/Server/lib/filename.jar

Where XX is a progressive number. If you're using relative paths it will be slightly different:

Code: Select all

wrapper.java.classpath.XX=lib/filename.jar


-> Running the server standalone (start.sh or start.bat)

Linux/Unix: open the start.sh script with your favorite text editor and add the jar files to the classpath parameter. Make sure to separate each entry with a colon ( : ).

Windows: open the start.bat script with your favorite text editor and add the jar files to the classpath parameter. Make sure to separate each entry with a semi-colon ( ; ).

Once this is done you should stop the server if it's running and start it again

cool

Posted: 22 Dec 2007, 13:03
by giorgio79
Sounds cool :)

Would you have some example scenarios when one would add a jar extension?

For example, I have a java server for some games, could I add that as an extension?

Posted: 02 Nov 2008, 03:55
by jamieyg3
I spent about 2 full days trying to get an external jar file to work (jdom for reading xml files) without success, and then i gave up, and now i find this thread. should have looked here earlier.

Posted: 03 Nov 2009, 10:57
by corwin
Hi, is it possible to reload used jar/java project runtime? With the described scenario you need to restart the server to reload jars, which is pretty uncomfortable.

Posted: 03 Nov 2009, 14:01
by Lapo
It is possible to reload extensions at runtime, but not jar files.
Extensions can be deployed directly to the javaExtensions folder.

I'd recommend to follow the documentation here:
http://www.smartfoxserver.com/docs/docP ... ons.htm#9a

Runtime reloading of jar file is coming in the next major update, due next year.

Posted: 04 Nov 2009, 08:33
by corwin
Ok, thanks for the info.

Unix

Posted: 18 Aug 2010, 12:27
by PeredereevBoris
When You add library onto start.sh be attentive after last library also should be ":" symbol

Re: [TUTORIAL] How to add new libraries (.jar files)

Posted: 08 Nov 2017, 08:38
by Onlyzen
its Good and thanks for information