Guide: How to compile a .jar file for your extension

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Guide: How to compile a .jar file for your extension

Postby BigFIsh » 31 Jul 2010, 11:49

Guide is based on NetBeans 6.8 IDE

1. Download & Install latest JDK 6
2. Open NetBeans, add a new Java Class Project.
3. Add required SFS .jar libraries
4. Right click on your project and change the Source/Binrary Format to JDK 6
5. Modify the build.xml file, and add the following to -post-compile (it will copy the .jar file to the SFS2X directory after the compile):

Code: Select all

<copy todir="{SFS2X path}\SFS2X\extensions\{your extension}\">
   <fileset file="${dist.jar}"/>
</copy>


6. Restart your server (in order for the server to pick up the new .jar file)
Smartfox's forum is my daily newspaper.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Aug 2010, 12:11

Step 6 is not even necessary. If you set your extension as AUTO-RELOAD in the config tool the jar file will be monitored and reloaded at runtime.

There's still a few optimizations we want to add to this hot-redeploy system but it's already working good.
Lapo
--
gotoAndPlay()
...addicted to flash games
peter.dalton
Posts: 11
Joined: 10 Aug 2010, 21:51

Postby peter.dalton » 20 Aug 2010, 20:22

Does anyone know how to debug the java server extensions? I found some help for SFS 1.6, however 2x doesn't seem to be the same.

Thanks,

- Peter
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Aug 2010, 14:51

Although I haven't tried you should proceed in the same way as for SFS1. The principle is the same. What problem do you have?
Lapo

--

gotoAndPlay()

...addicted to flash games
peter.dalton
Posts: 11
Joined: 10 Aug 2010, 21:51

Postby peter.dalton » 30 Sep 2010, 23:51

I have found documentation on how to debug SFS1:
viewtopic.php?t=1872

However it makes references to a file: Server\conf\wrapper.conf that I can't find anywhere or any file that seems to contain the referenced parameters.

Where would I find this information for SFS 2

Thanks,
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Oct 2010, 16:20

Hi,
the current SFS2X beta is launched via a .bat (Wind) or .sh (Linux) file.
You should edit your launcher file and add the following JVM switches:
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n


This will enable the remote debugging
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
jpardoe
Posts: 132
Joined: 31 Aug 2009, 20:54

Postby jpardoe » 27 Oct 2010, 11:48

I encountered a problem when editing the build.xml file. When compiling the extension, the build failed with an error saying "{project location}\dist not found."

I think the problem was caused because -post-compile is called before the JAR file has been created. Of course, if the file has already been created, the error never shows up. It only occurs when you do a clean and build.

I managed to resolve the problem by placing the code below in -post-jar instead.

Code: Select all

<copy todir="{SFS2X path}\SFS2X\extensions\{your extension}\">
   <fileset file="${dist.jar}"/>
</copy>
tommy408
Posts: 16
Joined: 26 Sep 2010, 05:13

Where

Postby tommy408 » 28 Oct 2010, 15:03

Where do these debug command lines go? On the next line, same line, inside the quotation?

-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n



sfs2x.bat file :

@java -cp "./;lib/*;lib/Jetty/*;extensions/__lib__/*" -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main $1 $2 $3
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 28 Oct 2010, 15:20

Same line, no quotations.
Like this:

@java -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend= -cp "./;lib/*;lib/Jetty/*;extensions/__lib__/*" -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main $1 $2 $3
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 31 Oct 2010, 19:39

Hi. which version of netbeans do i need to install?

Java SE, JavaFX, Java, Ruby, C/C++, PHP or All?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 01 Nov 2010, 09:21

Java SE is sufficient
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 01 Nov 2010, 13:38

thx.
lolandroll
Posts: 7
Joined: 30 Nov 2010, 17:15

NetBeans 6.9.1 and Windows 7

Postby lolandroll » 02 Dec 2010, 07:57

I found this http://www.smartfoxserver.com/docs/docP ... ions.htm#1 - is this equal to SFS2X and will help me set up and compile my First very Basic extension with my enviroment? Or maybe there is a step by step tutorial on how to do it that i can find on that forum?

many thanks
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Dec 2010, 08:07

Here:
http://docs2x.smartfoxserver.com/Advanc ... extensions
we explain the dependencies needed to compile an extension. It is just two files from the lib/ folder: sfs2x.jar and sfs2x-core.jar.

The tutorial you have found can help you to go through the various dialogues while configuring the IDE.

We'll soon publish a step by step tutorial for SFS2X too
Lapo

--

gotoAndPlay()

...addicted to flash games
lolandroll
Posts: 7
Joined: 30 Nov 2010, 17:15

my enviroment

Postby lolandroll » 03 Dec 2010, 06:59

Thanks for help - enyway i forgot to add that i'am using Win7 an NetBeans 6.9.1 IDE.

"We'll soon publish a step by step tutorial for SFS2X too" - I'll be waiting impatiently for this.

Cheers

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 37 guests