[HowTo] Debugging java extensions in Netbeans

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Godai
Posts: 29
Joined: 23 Jan 2009, 12:14

[HowTo] Debugging java extensions in Netbeans

Postby Godai » 30 Sep 2009, 12:39

How to setup Smartfox java extension debugging

Step 1
Download the Netbeans IDE for java development. (47mb SE version should be fine!)

Step 2
Install and open Netbeans. Create a project from existing java source pointing to where your extensions are. Should be placed in src subfolder to be nice.
(I for sure could not make it work if the source was not in a subfolder)

Right click on project and choose properties->libraries. Add all jar files from your smartfox installation lib dir.

Step 3
Goto Files tab. Expand nbbuild.xml. Click on -post-compile target.

Copy and paste the following code: (Note: adjust todir to point to your smartfox program extension directory)

<copy todir="C:\Programmer\SmartFoxServerPRO_1.6.6\Server\javaExtensions">
<fileset dir="${build.dir}/classes/"/>
</copy>

Step 4
Create a new batchfile called SmartFoxDebug?.bat

Copy and paste the following content into it: (Again adjust to your installation directory)

C:\Programmer\SmartFoxServerPRO_1.6.6\Server\wrapper.exe -c "C:\Programmer\SmartFoxServerPRO_1.6.6\Server\conf\wrapper.conf"

Step 5
Add the following lines to your wrapper.conf

Code: Select all

# runtimedebug
wrapper.java.additional.3=-Xdebug
wrapper.java.additional.4=-Xnoagent
wrapper.java.additional.5=-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n


Step 6
Choose Run->Build main project (F11) in Netbeans.

If build is ok, click the batch file. Now select debug->attach debugger and choose port 8888. Debugger console should say "User program running".

Now you can place breakpoints and trigger your extensions normally.

NOTE: Just a quick 5 minute job. You can autolaunch smartfox and whatnot given some more effort
Last edited by Godai on 30 Sep 2009, 15:34, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 30 Sep 2009, 14:57

Godai,
thanks for the how-to.
I am making your post a sticky.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 05 May 2010, 03:00

Thanks for this information, very handy!

Just couple of things to clear up:

Step 3: I was confused about what this does for a bit. What it actually does is that after compiling your .java file, it copies the .class file from {build.dir}/classes/ to {smartfoxserver installation path}/Server/javaExtensions/ - ready for use.

Step 4: Missing quotes - the correct content is: "C:\Programmer\SmartFoxServerPRO_1.6.6\Server\wrapper.exe" -c "C:\Programmer\SmartFoxServerPRO_1.6.6\Server\conf\wrapper.conf" - open up your favourite text editor, paste that content and save as "SmartFoxDebug.bat". Double clicking on the file will lanuch SmartFoxServer as a Java Virtual Machine (JVM), or a.k.a Wrapper.

Step 5: 8888 is a port used for communication between NetBean's debugger and the wrapper. Don't use your server port here.

Step 6: As of NetBeans IDE 5.5, the "Attach Debuuger" is now relocated in "Run" dropdown menu. Ensure you use the same port (8888).
Smartfox's forum is my daily newspaper.
zkidkid
Posts: 39
Joined: 21 Mar 2011, 12:26
Contact:

Postby zkidkid » 22 Mar 2011, 16:34

Hi Godai

At the Step 3: I don't find any nbbuild.xml
I am using NetBean IDE 6.9.1 and I just find build.xml
Tell me if it right or wrong please.

At step 4, I don't know where to put my bat file. so I have put it in my project folder.
At step5. In my wrapper.conf has already has wrapper.java.additional.3 =-***
so I have changed from :
# runtimedebug
wrapper.java.additional.3=-Xdebug
wrapper.java.additional.4=-Xnoagent
wrapper.java.additional.5=-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n

to
# runtimedebug
wrapper.java.additional.4=-Xdebug
wrapper.java.additional.5=-Xnoagent
wrapper.java.additional.6=-Xrunjdwp:transport=dt_socket,address=8888,server=y,suspend=n

whether it's ok ?

and at final step ( step 6)
I has build and select attach debugger but it show strange windows.

I have pictured it here.
Image

I really need your help urgenly.
User avatar
AndyMartin458
Posts: 55
Joined: 15 May 2012, 21:57

Re: [HowTo] Debugging java extensions in Netbeans

Postby AndyMartin458 » 12 Mar 2014, 04:44

Are there any ways to do this on OSX? I've done it on Windows many times, but I was wondering how to do is with a .sh instead of a .bat
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: [HowTo] Debugging java extensions in Netbeans

Postby Lapo » 12 Mar 2014, 10:27

Most of the changes are applied to the wrapper.conf file. What is exactly that you don't know how to do on MacOS X?
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: Google [Bot] and 25 guests