Error: Could not find or load main class com.smartfoxserver.v2.Main

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

Moderators: Lapo, Bax

moustafaSamy
Posts: 5
Joined: 08 Jun 2023, 07:23

Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby moustafaSamy » 08 Jun 2023, 07:32

Hi,
when i try to run sfs2x.sh on my mac i got this error
Error: Could not find or load main class com.smartfoxserver.v2.Main
Caused by: java.lang.ClassNotFoundException: com.smartfoxserver.v2.Main
how can i fix this please
thanks in advance,
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby Lapo » 08 Jun 2023, 09:43

Hi,
what version of SmartFoxServer are you using?
Also what macOS version are you using?

Although we recommend launching the server via the native app provided under the SFS2X/ folder you can also use the sfs2x.sh script, which is expected to work out of the box (unless you have moved other files around).

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
moustafaSamy
Posts: 5
Joined: 08 Jun 2023, 07:23

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby moustafaSamy » 08 Jun 2023, 09:51

smartfox version : SFS2X_macos_2_19_0
macOS version : ventura 13.4
i didn’t move any folders actually i removed smartfox and re installed it
then i tried to use sfs2x.sh
and still getting this error
Error: Could not find or load main class com.smartfoxserver.v2.Main
Caused by: java.lang.ClassNotFoundException: com.smartfoxserver.v2.Main

thanks in advance,
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby Lapo » 08 Jun 2023, 13:00

Thanks,
we have tested on numerous macOS versions, including Ventura and there is no problem.
Can you run the the server via the SFS2X app?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Void*
Posts: 77
Joined: 15 Feb 2021, 13:49

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby Void* » 08 Jun 2023, 13:10

@moustafaSamy are you starting the script via double-click from Finder? This will generally set the working directory to your Home directory instead of the SFS2X directory which could lead to relative path problems. Try starting it in a terminal window instead if this is the case, or like Lapo said, use the mac native app instead.
moustafaSamy
Posts: 5
Joined: 08 Jun 2023, 07:23

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby moustafaSamy » 08 Jun 2023, 13:21

Hi,
i run the script via terminal bash <drag and drop the script>

i also tried to run the SFS2X app instead and it worked but when i replace the extensions and lib folders with the ones for my game server to run a local test and then run the SFS2X app again i got the same error on the app
Attachments
Screenshot 2023-06-08 at 3.56.58 PM.png
(206.84 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby Lapo » 08 Jun 2023, 15:08

moustafaSamy wrote:Hi,
i run the script via terminal bash <drag and drop the script>

You should cd into the folder and the run the script:

Code: Select all

cd <SFS2X-Installation>/SFS2X/
./sfs2x.sh

i also tried to run the SFS2X app instead and it worked but when i replace the extensions and lib folders with the ones for my game server to run a local test and then run the SFS2X app again i got the same error on the app

the SFS2X/lib/ folder should not be replaced. In there are locate all the necessary files and libraries to run the server.

You should deploy your Extensions and extensions libraries under SFS2X/extensions/ and SFS2X/extesions/__lib__/ respectively

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
moustafaSamy
Posts: 5
Joined: 08 Jun 2023, 07:23

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby moustafaSamy » 09 Jun 2023, 06:31

ok when i dont replace lib folder it works fine
however i cant run my local test
so do you mean i should
-copy extensions folder content from (deploy/extensions) to (SFS2X/extensions)
-copy lib folder content from (deploy/lib) to (SFS2X/extensions/__lib__)
or i am doing it wrong ?
thanks in advance
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby Lapo » 09 Jun 2023, 07:59

I don't know what IDE you're using, but in any case once you have generated your jar file you should follow the documentation here:
http://docs2x.smartfoxserver.com/Extens ... uick-start

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
moustafaSamy
Posts: 5
Joined: 08 Jun 2023, 07:23

Re: Error: Could not find or load main class com.smartfoxserver.v2.Main

Postby moustafaSamy » 09 Jun 2023, 08:42

thanks alot
you can consider this done
its working now

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 96 guests