Minecraft modded server "illegal access error"

Whenever I try to run a mod server I get this message. Any ideas on how to fix it?

Error message:
"Exception in thread “main” java.lang.IllegalAccessError: class cpw.mods.modlauncher.SecureJarHandler (in unnamed module @0x527e5409) cannot access class sun.security.util.ManifestEntryVerifier (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x527e5409
at cpw.mods.modlauncher.SecureJarHandler.lambda$static$1(SecureJarHandler.java:45)
at cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck(LamdbaExceptionUtils.java:95)
at cpw.mods.modlauncher.SecureJarHandler.(SecureJarHandler.java:45)
at cpw.mods.modlauncher.Launcher.lambda$new$6(Launcher.java:55)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:52)
at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:47)
at cpw.mods.modlauncher.Environment.computePropertyIfAbsent(Environment.java:62)
at cpw.mods.modlauncher.Launcher.(Launcher.java:55)
at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)
at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63)
at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60)
at net.minecraftforge.server.ServerMain.main(ServerMain.java:57)
"

I have both java 8 and java 17 SE development kit installed.

What java does the modpack call for

Sorry, I should have prefaced with this:

I have all of the files for the server that the modpack needs and I try using said files when attempting to run the server. I probably did something wrong there, but hopefully this helps

This is not what i asked. The error states that something is trying to use java sun packages that are no longer accessible in recent java versions

Maybe uninstall this weird java and get for the mod another java version. try maybe Java 8 (jre1.8.0_291)