4
java -server -Xmx2G -cp config:./* l2p.loginserver.LoginServer

MAC: OK!
WINDOWS: Cannot find class l2p.loginserver.LoginServer
LINUX: Cannot find class l2p.loginserver.LoginServer

Aditional info: jar file is called kernel.jar and it's in the same folder where the command is executed

if i use java -server -cp kernel.jar l2p.loginserver.LoginServer the class is started to load but i need config because i have log4j xml there. Thanks!

Hari Menon
  • 33,649
  • 14
  • 85
  • 108

2 Answers2

2

See this answer

In java classpath, if you use wildcard *, it only loads the .jar files from that location.

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

Problem with log4j is that the first log4j.xml in the classpath will be loaded. So put the config in front.

Community
  • 1
  • 1
Hari Menon
  • 33,649
  • 14
  • 85
  • 108
  • The .conf files wouldn't be valid classpath entries though, would they? It sounds like it's genuinely the config *directory* which needs to be in the classpath. – Jon Skeet Jun 16 '12 at 08:35
  • that does not help me, as i said i am loading a jar file named kernel.jar – kodeslacker Jun 16 '12 at 08:37
  • @user1460357 can you try this - create a dummy property file `props` in the config directory with some dummy value "xyz=abc", then load it in your class as `props.load(this.class.getClassLoader().getResourceAsStream("props")); System.out.println(props.get("xyz"));`. Just to make sure that the problem is with the classpath setting. – Hari Menon Jun 16 '12 at 09:01
0

I don't think you can use globbing like that in a -cp argument. They won't be expanded in the right way, colon-separated as you need them. Try

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

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

Note that this is assuming you're on Unix. On Windows you'd need

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

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

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194