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

hamish
Posts: 6
Joined: 13 Dec 2010, 16:49
Location: UK
Contact:

Step by Step SFSx2 debugging

Postby hamish » 14 Dec 2010, 11:54

Step by Step SFSx2 extension debugging

Hi just went through this process and thought i'd post it to make it easy for everyone, coz there are a few errors in the posts i've read.

I'm using eclipse IDE for java developers 3.6.1, and sfs2x server is running on my local machine, on windows xp

backup the bat file at

install folder/SFS2X/sfs2x.bat

edit the file with notepad and replace what's there with

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

go to eclipse

run/debug configurations...

right click Remote Java Application and choose Add...

make sure the connection properties are set to
host: localhost
Port: 8787

double click the bat file you edited.

the cmd window should appear and say

Listening for transport dt_socket at address 8787

press the little green bug in eclipse to start the debugging session ( i found i had to click the little arrow next to it and select my extension name)

when you start the debugging session the SFSx2 server should start as normal

set some breakpoints in your extension code.

and enjoy.
Last edited by hamish on 24 Jan 2011, 15:54, edited 1 time in total.
lolandroll
Posts: 7
Joined: 30 Nov 2010, 17:15

Postby lolandroll » 19 Dec 2010, 09:03

Does enyone can tell how to recompile the expamles from that page:

http://docs2x.smartfoxserver.com/Develo ... se-recipes

becouse I wanted to chage database name for something else and changing it in java filese doesn't seems to work

#########################
Nevermind -
i saw that lapo add new tutorial in the docs

http://docs2x.smartfoxserver.com/Develo ... extensions

:) That would help
User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

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

Postby levancho » 22 Feb 2012, 11:54

just want to contribute my approach.

I use executable instead of bat file so in that case editing : sfs2x-standalone.vmoptions was sufficient for me to get debugger working.

I added :

Code: Select all

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


and just to make sure debugger is working, you should see something like his in startup console (at the begining) :

Code: Select all

Listening for transport dt_socket at address: 8787
huhailong
Posts: 28
Joined: 14 May 2010, 04:39

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

Postby huhailong » 14 Jan 2013, 03:45

does all java class for a zone need to put to one xxxExtension.jar ?
because i have a problem: i create a class MyOSExtension extends OpenSpaceExtension, this class will create all room and other data when sfs2x start,
i put this class to fox2Extension.jar, this jar also has some other class to handle the client request,
right now i changed some other class and export to fox2Extension.jar,
class MyOSExtension didn't change, but when jar replaced, the class MyOSExtension automaticlly running, so it will create all room again but failed.
if class MyOSExtension runned again, it will occur issue for our sfs game.
the issue log is :
11:35:03,168 INFO [com.smartfoxserver.v2.controllers.ExtensionController-3] utils.Logger - [OpenSpace] User dragon [0] requested path from (52, 56, 0) to (56, 58, 0) on map 'floors/b801_fn1#A'
11:35:03,172 ERROR [com.smartfoxserver.v2.controllers.ExtensionController-3] utils.Logger - [OpenSpace] java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: An unexpected exception occurred while the OpenSpace Core Extension executed command path
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.openspace.commands.CalculatePathCommand.execute(CalculatePathCommand.java:84)
com.smartfoxserver.openspace.handlers.OSRequestHandler.handleClientRequest(OSRequestHandler.java:81)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:192)
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:133)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

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

Postby Bax » 15 Jan 2013, 09:46

huhailong, please don't double-post: viewtopic.php?p=66043#p66043
Paolo Bax
The SmartFoxServer Team
FCrocetti
Posts: 2
Joined: 19 Apr 2013, 01:40

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

Postby FCrocetti » 19 Apr 2013, 10:07

Hello,

I'm having issues on listing in the zone extension list my custom jars compiled from Netbeans 7.1, I don't succeed neither on SFS2X for OSX 10.8 nor for Windows 7. I have to say that I'm completely newbie in Java (but I'm a senior programmer in a bunch of other languages so it's not a problem), but I followed these steps and the video tutorial though my extension is not listed.

I don't succeed to list neither a "hello world" extension like this:

Code: Select all

import com.smartfoxserver.v2.extensions.SFSExtension;

public class testSfsExtension extends SFSExtension {

    @Override
    public void init() {
        trace("***[ Test Sfs Extension loaded ]***");
    }
   
}


Since moving your TrisExtension.jar to my folder in /extensions makes my folder to be correctly listed in Zone manager (but my classes are not listed in the Main classes), I can only suppose it has something to do with how I'm compiling.

You can find the project source (very small, it is the example above) here, it contains the Netbeans project folder so you can see both source and the compiled jar (in the folder /dist). By the way in the project settings I have Source/Binary Format=JDK6 and Encoding=UTF-8, you can take a look at the screenshot here.

Thank you in advance, best regards.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 19 Apr 2013, 10:19

Hi,
a few suggestions.

1- Please do use a package declaration in your classes
2- Please always start a class name with a capital letter (TestSfsExtension not testSfsExtension)
3- Follow the SFS2X jar naming convention: <AnyName>Extension.jar, e.g.: MyCoolExtension.jar, GameExtension.jar, PokerExtension.jar etc...

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
FCrocetti
Posts: 2
Joined: 19 Apr 2013, 01:40

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

Postby FCrocetti » 19 Apr 2013, 11:58

Great! It worked, I don't know if it was because of first capital letter renaming on the extension class or the suffix "Extension" to jar filename or both, however now they're listed and I can continue testing! It's probably useful to append these hints to the topic message.

Thanks
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

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

Postby Bax » 22 Apr 2013, 10:22

The problem was the "Extension" suffix.
This is described in the doc too.
Paolo Bax
The SmartFoxServer Team
AdrianG001
Posts: 3
Joined: 20 Apr 2018, 15:53
Contact:

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

Postby AdrianG001 » 23 Apr 2018, 14:23

FCrocetti wrote:Great! It worked, I don't know if it was because of first capital letter renaming on the extension class or the suffix "Extension" to jar filename or both, however now they're listed and I can continue testing! It's probably useful to append these hints to the topic message.

Thanks


which version of netbeans do i need to install?

Java SE, JavaFX, Java, Ruby, C/C++, PHP or All?

Regards,
Adrian Gates
Sr. Developer - Apps4Rent
Last edited by AdrianG001 on 15 Nov 2018, 18:08, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 23 Apr 2018, 16:07

Hi,
the JavaSE version is fine for developing with SFS2X.
The other stuff can be useful if you plan to develop for those platforms, otherwise it will just take more installation space.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
houssein9
Posts: 2
Joined: 13 May 2018, 20:04
Location: Egypt
Contact:

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

Postby houssein9 » 13 May 2018, 20:12

thank you so much!!! amazing.
Chakir Nasri
Senior actionscript developer
http://www.nojomgames.com/
AdrianG001
Posts: 3
Joined: 20 Apr 2018, 15:53
Contact:

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

Postby AdrianG001 » 15 Nov 2018, 18:17

Is there any alternative for netbeans which is almost similar to netbeans. I`m facing difficulties in installing netbeans on my new citrix vdi system

Regards,
Adrian Gates
Last edited by AdrianG001 on 21 Nov 2018, 15:02, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 16 Nov 2018, 08:23

Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
LordDawn
Posts: 42
Joined: 15 Apr 2019, 08:36

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

Postby LordDawn » 16 Apr 2019, 13:25

I'm following the guide, I have the latest Java and Eclipse, and have written a demo hello world extension, but when I add the Jar file into the extensions/MyExtension folder, and restart the clean install of smartfox, it crashes out. I can't find any log that shows an error as to why this happens. Remove the extension jar file and it starts up fine (though issues a warning that the MyExtension folder contains no jar file.

I guess this means that there's something wrong with my jar file, but I'm unsure what, as there are no errors or warnings issued that I can see. The code it the same as in the tutorial. Really very simple. Pretty sure this is just a beginners issue, and I'm missing something or have something wrong.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 43 guests