Java class -cp not found

java -server -Xmx2G -cp config:./* l2p.loginserver.LoginServer MAC: OK! WINDOWS: Cannot find class l2p.loginserver.LoginServer LINUX: Cannot find class l2p.loginserver.LoginServer 

Additional information: the jar file is called kernel.jar, and it is located in the same folder in which the command is executed

if I use java -server -cp kernel.jar l2p.loginserver.LoginServer, the class starts to load, but I need config, because I have log4j xml. Thanks!

+4
source share
2 answers

See this answer

In java classpath, if you use * wildcard, it only downloads .jar files from this location.

 java -server -Xmx2G -cp config:kernel.jar l2p.loginserver.LoginServer 

The problem with log4j is that the first log4j.xml will be loaded in the classpath. Therefore, put the configuration in front.

+2
source

I do not think you can use a similar globe in the -cp argument. They will not be expanded in the right direction, separated by a colon if you need to. Try

 java -cp config:kernel.jar l2p.loginserver.LoginServer 

(With the other arguments you need, of course.)

Please note that it is assumed that you are on Unix. On Windows you will need

 java -cp config;kernel.jar l2p.loginserver.LoginServer 

(path separator ; on Windows, but : on Unix.)

0
source

All Articles