Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having an error trying to run GUI #3

Open
NerijusD opened this issue Apr 4, 2020 · 8 comments
Open

Having an error trying to run GUI #3

NerijusD opened this issue Apr 4, 2020 · 8 comments

Comments

@NerijusD
Copy link

NerijusD commented Apr 4, 2020

@NerijusD Hi!

after ant dist run
cd build/distr and
java -cp "libs/*:libs/slik2d/*" fw.gui.MainSwingForm
for run gui form

Originally posted by @xMlex in #2 (comment)

This did not fix the problem, running java -cp "libs/*:libs/slik2d/*" fw.gui.MainSwingForm I getting Error: Could not find or load main class fw.gui.MainSwingForm

@fmpoffice
Copy link

@NerijusD Hi!

after ant dist run
cd build/distr and
java -cp "libs/*:libs/slik2d/*" fw.gui.MainSwingForm
for run gui form

Originally posted by @xMlex in #2 (comment)

This did not fix the problem, running java -cp "libs/*:libs/slik2d/*" fw.gui.MainSwingForm I getting Error: Could not find or load main class fw.gui.MainSwingForm

1、coyp l2walk.jar to l2walk\build\distr
2、change StartServer.bat edit:l2walker.jar fw.gui.MainSwingForm

@NerijusD
Copy link
Author

NerijusD commented Apr 6, 2020

@fmpoffice I did try your suggestion, but it didn't work or simply I didn't do it correctly.

StartServer.bat on line 7, contains:
java -server -Xms32m -Xmx64m -cp libs/*;libs/slik2d/*; fw.gui.MainAppForm
I did try replacing this line with:
java -server -Xms32m -Xmx64m -jar l2walker.jar fw.gui.MainSwingForm however still gave an error of Error: Could not find or load main class fw.gui.MainAppForm

Then I tried also:
java -server -Xms32m -Xmx64m -cp libs/*;libs/slik2d/*; fw.gui.MainAppForm -jar l2walker.jar fw.gui.MainSwingForm still have error:
Error: Could not find or load main class fw.gui.MainAppForm

What else is not right? Could it be my installation of Java?

@xMlex
Copy link
Owner

xMlex commented Apr 7, 2020

See https://github.com/xMlex/l2walker/blob/master/data/config/StartServer.bat#L7
Updated command to run in commit aca4330

And see README.md - section Build & run: https://github.com/xMlex/l2walker#build--run

@NerijusD
Copy link
Author

NerijusD commented Apr 7, 2020

I got latest fresh version of this, then following your Build and Run:

C:\Users\nd\Desktop\l2walker-master>ant dist
Buildfile: C:\Users\nd\Desktop\l2walker-master\build.xml

clean:

init:
    [mkdir] Created dir: C:\Users\nd\Desktop\l2walker-master\build\classes
    [mkdir] Created dir: C:\Users\nd\Desktop\l2walker-master\build\distr

compile:
    [javac] Compiling 367 source files to C:\Users\nd\Desktop\l2walker-master\build\classes
    [javac] C:\Users\nd\Desktop\l2walker-master\java\fw\connection\socks\ListenerIntelude.java:205: warning: [unchecked] unchecked call to setClient(T) as a member of the raw type BaseSendableSocketPacket
    [javac]         msg.setClient(this);
    [javac]                      ^
    [javac]   where T is a type-variable:
    [javac]     T extends ISocksListener declared in class BaseSendableSocketPacket
    [javac] C:\Users\nd\Desktop\l2walker-master\java\fw\connection\socks_login\LitenerInterludeLogin.java:47: warning: [unchecked] unchecked call to setClient(T) as a member of the raw type BaseSendableSocketPacket
    [javac]             pkt.setClient(this);
    [javac]                          ^
    [javac]   where T is a type-variable:
    [javac]     T extends ISocksListener declared in class BaseSendableSocketPacket
    [javac] C:\Users\nd\Desktop\l2walker-master\java\fw\extensions\geodata\ZoneManager.java:191: warning: [deprecation] setShared(boolean) in FastMap has been deprecated
    [javac]             _zonesByType = new FastMap<ZoneType, GArray<L2Zone>>().setShared(true);
    [javac]                                                                   ^
    [javac]   where K,V are type-variables:
    [javac]     K extends Object declared in class FastMap
    [javac]     V extends Object declared in class FastMap
    [javac] C:\Users\nd\Desktop\l2walker-master\java\fw\extensions\util\Files.java:13: warning: [deprecation] setShared(boolean) in FastMap has been deprecated
    [javac]     private static final FastMap<String, String> cache = new FastMap<String, String>().setShared(true);
    [javac]                                                                                       ^
    [javac]   where K,V are type-variables:
    [javac]     K extends Object declared in class FastMap
    [javac]     V extends Object declared in class FastMap
    [javac] C:\Users\nd\Desktop\l2walker-master\java\fw\extensions\util\MultiValueIntegerMap.java:16: warning: [deprecation] setShared(boolean) in FastMap has been deprecated
    [javac]             map = new FastMap<Integer, GCSArray<Integer>>(10).setShared(true);
    [javac]                                                              ^
    [javac]   where K,V are type-variables:
    [javac]     K extends Object declared in class FastMap
    [javac]     V extends Object declared in class FastMap
    [javac] C:\Users\nd\Desktop\l2walker-master\java\fw\extensions\util\MultiValueMap.java:15: warning: [deprecation] setShared(boolean) in FastMap has been deprecated
    [javac]             map = new FastMap<K, GArray<V>>(10).setShared(true);
    [javac]                                                ^
    [javac]   where K,V are type-variables:
    [javac]     K extends Object declared in class FastMap
    [javac]     V extends Object declared in class FastMap
    [javac] 6 warnings

jar:
      [jar] Building jar: C:\Users\nd\Desktop\l2walker-master\build\l2walker.jar

dist_common:
     [copy] Copying 3 files to C:\Users\nd\Desktop\l2walker-master\build\distr
    [mkdir] Created dir: C:\Users\nd\Desktop\l2walker-master\build\distr\log
    [mkdir] Created dir: C:\Users\nd\Desktop\l2walker-master\build\distr\libs
     [copy] Copying 20 files to C:\Users\nd\Desktop\l2walker-master\build\distr\libs
    [mkdir] Created dir: C:\Users\nd\Desktop\l2walker-master\build\distr\libs\slik2d
     [copy] Copying 32 files to C:\Users\nd\Desktop\l2walker-master\build\distr\libs\slik2d
 [copyfile] DEPRECATED - The copyfile task is deprecated.  Use copy instead.
     [copy] Copying 3430 files to C:\Users\nd\Desktop\l2walker-master\build\distr\data

dist:

BUILD SUCCESSFUL
Total time: 38 seconds

C:\Users\nd\Desktop\l2walker-master>cd build/distr

C:\Users\nd\Desktop\l2walker-master\build\distr>java -cp "libs/*:libs/slik2d/*" fw.gui.MainSwingForm
Error: Could not find or load main class fw.gui.MainSwingForm

I am running on Windows 10 with JAVA_SDK 8

@NerijusD
Copy link
Author

NerijusD commented Apr 7, 2020

Also try to start from script:

C:\Users\nd\Desktop\l2walker-master\build\distr>StartServer.bat
Starting xMlex Server.

Error: Could not find or load main class fw.gui.MainSwingForm

Server terminated abnormaly


server terminated

Press any key to continue . . .

@gigstox
Copy link

gigstox commented Mar 2, 2022

I have a similar problem, is there a solution?

@melg8
Copy link

melg8 commented Oct 21, 2024

@NerijusD, @gigstox, @xMlex it took only 4 years, i think i figured this one out

Issue was that in build.xml file its written as:

<attribute name="Main-Class" value="fw.gui.MainAppForm" />

As you can see - MainAppForm.

But actually in files it is MainSwingForm

public class MainSwingForm extends Frame {

And for running it i used this bat file:

"C:\Program Files\Java\jre1.8.0_431\bin\java.exe" -jar l2walker.jar -cp "libs/*:libs/slik2d/*" fw.gui.MainSwingForm
pause

So you should have in build.xml MainSwingForm instead of MainAppForm, then it starts up, although i now get this error message:

15:44:46.956  Console configured.
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/opengl/AWTGLCanvas
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at fw.gui.MainSwingForm.makeTextPanel(Unknown Source)
        at fw.gui.MainSwingForm.initGUI(Unknown Source)
        at fw.gui.MainSwingForm.<init>(Unknown Source)
        at fw.gui.MainSwingForm.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.AWTGLCanvas
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 16 more

@melg8
Copy link

melg8 commented Oct 30, 2024

I've revisited my bat file, this is version that works correctly:

"C:\Program Files\Java\jre1.8.0_431\bin\java.exe" -cp "build/distr/libs/*;build/distr/libs/slik2d/*;build/l2walker.jar" fw.gui.MainSwingForm
pause

My second problem was that using -cp and -jar commands at same time prevent -cp from running at all according to this answer

So when using only -cp command instead we achieve load of both l2walker part and lwjgl into program.
So now it starts bot properly:
image

So for anyone interested, full list of actions to do, for this program to run is:

To run bot

  1. download source code
  2. change MainAppForm -> MainSwingForm in this line:
    <attribute name="Main-Class" value="fw.gui.MainAppForm" />
  3. create run.bat in root of source code folder containing:
"C:\Program Files\Java\jre1.8.0_431\bin\java.exe" -cp "build/distr/libs/*;build/distr/libs/slik2d/*;build/l2walker.jar" fw.gui.MainSwingForm
pause

Keep in mind that your path of java might be different, so you will need to check where your jre (java runtime environment) is installed on your pc and change this part "C:\Program Files\Java\jre1.8.0_431\bin\java.exe" accordingly.
You can try shorter version:

java.exe -cp "build/distr/libs/*;build/distr/libs/slik2d/*;build/l2walker.jar" fw.gui.MainSwingForm
pause
  1. run ant in root of source directory
  2. run run.bat in root of source code directory

All of this were tested on windows 10. For linux should be similar with maybe usage of java instead of java.exe naming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants