GUIDE: Using Java 8 with SFS2X

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
aakture
Posts: 23
Joined: 05 Jun 2012, 18:46

Re: GUIDE: Using Java 8 with SFS2X

Postby aakture » 28 Oct 2015, 03:28

You said "then launch SFS2X via start.sh", I think you meant "then launch SFS2X via sfs2x.sh", correct?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: GUIDE: Using Java 8 with SFS2X

Postby Lapo » 28 Oct 2015, 08:26

aakture wrote:You said "then launch SFS2X via start.sh", I think you meant "then launch SFS2X via sfs2x.sh", correct?

Yep sorry, you're right. Confused it with SFS PRO.
It is fixed now.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
coolboy714cp
Posts: 323
Joined: 06 Feb 2010, 02:45
Contact:

Re: GUIDE: Using Java 8 with SFS2X

Postby coolboy714cp » 16 Feb 2017, 04:59

How do we upgrade the JRE now that SFS2X comes pre-packaged with Java 8 Runtime? For some reason The SFS2X/lib/jetty/modules/npn folder no longer exists.. SFS still starts though. There is a alpn-impl folder there instead though..?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: GUIDE: Using Java 8 with SFS2X

Postby Lapo » 16 Feb 2017, 08:24

Hi,
since version 2.12 you can just replace the JRE folder directly.
(Naturally the JRE must be version 8 or higher)

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
ManHo
Posts: 1
Joined: 20 Jun 2017, 11:36

Re: GUIDE: Using Java 8 with SFS2X

Postby ManHo » 20 Jun 2017, 11:37

My Expression
thanks for the blog very interesting
The easiest way to get up and running is simply to install Java 8 and then launch SFS2X via sfs2x.sh script in the terminal. There actually a total of 4 ways to launch SFS2X on the Mac :( Three of which depend on the embedded JRE and require further hacking into the shell scripts.
Thanks You!
gclub casino
goldenslot
gclub casino
patman
Posts: 5
Joined: 03 Dec 2020, 16:20

Re: GUIDE: Using Java 8 with SFS2X

Postby patman » 03 Dec 2020, 16:45

Hello,

I am new to Smart Fox and spent the last month reading the documentation and going the through the various Unity tutorials available via the SFS2X docs found on the website. I didn't realize there was an Asset Package on the store until today :D but nonetheless everything worked relatively flawlessly.

However when I made my own extension I found the extension kept not being initialized. I found somewhere that the extension needs to be compiled with the JRE as Smart Fox. So I figured I just needed to update the jre but every time I replace the Smart Fox jre folder the server won't start back up again with a 1067 error. I had backed up the original jre folder incase I ran into problems so I was able to bring it back. After which my server can start up again.

Ultimately my questions are,

- am I going down the correct avenue here? The initial problem was the extension not being initialized. Would the fact that it was complied with Java 11 effect the initialization?

- If both of the previous questions are yes, What am I doing wrong? I followed the instructions 1 & 2 but when I do the server won't start again.

any help will great thank you!
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: GUIDE: Using Java 8 with SFS2X

Postby Lapo » 03 Dec 2020, 17:12

Hi,
- am I going down the correct avenue here? The initial problem was the extension not being initialized. Would the fact that it was complied with Java 11 effect the initialization?

All you need to do is write the Extension code in a Java IDE (Eclipse, NetBeans, IntelliJ...) and compile it to a jar file, which then is deployed under the SFS2X/extensions/ folder.

Here's a step by step guide:
http://docs2x.smartfoxserver.com/Extens ... extensions

Would the fact that it was complied with Java 11 effect the initialization?

Yes.
SmartFoxServer 2X runs by default with Java 8, so Extension code compiled for a higher Java version will not work.
You have two options:

1- Set your compiler to be compatible with Java 8 (it's a setting found in the build options of every Java IDE)
2- Replace the default Java Runtime provided with SFS2X with a Java Runtime 11

Normally we recommend to use the former rather than the latter, but if you know what you're doing option 2 is also viable.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
patman
Posts: 5
Joined: 03 Dec 2020, 16:20

Re: GUIDE: Using Java 8 with SFS2X

Postby patman » 03 Dec 2020, 20:33

Awesome,

Thanks!

I followed that guide to produce the initial jar files but thank you. I actually have your docs bookmarked at the moment for references.

Thank you for that I did not know that I could change that in the java IDE! I think this should work. thank you!
patman
Posts: 5
Joined: 03 Dec 2020, 16:20

Re: GUIDE: Using Java 8 with SFS2X

Postby patman » 04 Dec 2020, 15:05

Forgot to thank you and say that it works now. My extensions are now being initialized by the server.

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

Re: GUIDE: Using Java 8 with SFS2X

Postby Lapo » 04 Dec 2020, 15:44

Great :)
Lapo

--

gotoAndPlay()

...addicted to flash games
Luke64
Posts: 21
Joined: 08 Nov 2020, 23:15

Re: GUIDE: Using Java 8 with SFS2X

Postby Luke64 » 20 Dec 2020, 21:50

Hi Lapo,

Lapo wrote:You have two options:

1- Set your compiler to be compatible with Java 8 (it's a setting found in the build options of every Java IDE)
2- Replace the default Java Runtime provided with SFS2X with a Java Runtime 11

Normally we recommend to use the former rather than the latter, but if you know what you're doing option 2 is also viable.


When starting SFS2X with most recent JRE 11.0.9 it issues a warning:

Code: Select all

$ ./sfs2x.sh
21:42:17,896 INFO  [main] v2.SmartFoxServer     - Boot sequence starts...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/home/sfs2x/SmartFoxServer_2X/SFS2X/lib/xstream-1.3.1.jar) to field java.util.Properties.defaults
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
21:42:18,419 INFO  [main] core.SFSEventManager     - SFSEventManager initialized


Of course it's just a warning, so I just wanted to pass it on in case you're thinking about updating that dependency anyway or so. ;)

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

Re: GUIDE: Using Java 8 with SFS2X

Postby Lapo » 21 Dec 2020, 10:45

Yes this expected and not an issue with any JRE version >= 9.
No worries.
As regards updating the dependencies, it's not going to happen for SFS2X. It's just way too much work, as too many features rely on pre-Java 9 reflection.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 41 guests