natinusala
natinusala

Reputation: 616

Classpath error on Mac OS

I made a Java application which runs another Java code using the java -cp "xxx.jar;xxx.jar" net.minecraft.client.main.Maincommand. The ; (or :depending on the OS) between the two JAR of the classpath is provided by the System.getProperty("path.separator") function.

On Windows it works fine, but not on Mac OS. Java says it cannot find or load main class net.minecraft.client.main.Main. I checked, the JARS of the classpath are correctly spelled and existing on the hard drive at the proper path.

Here is the whole command (/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java is the path to the Java executable) :

http://pastebin.com/8V3pg07q

Could you help me ? I am NOT requiring help on how to play Minecraft, it is not the official launcher (it is one I've made, which obviously doesn't work on Mac OS), so don't tell me to ask help at Minecraft Forums :P

Thanks !

Upvotes: 0

Views: 910

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1499770

It's not clear what you meant by "I tested forcing usage of ; even on Mac OS" but basically you should use the right path separator for the platform when you run the new Java process.

So on Windows you'd want:

java -cp xxx.jar;yyy.jar

On Unix you'd want

java -cp xxx.jar:yyy.jar

In the code where you're building the command line arguments, just make sure you use the path.separator property (or more simply File.pathSeparator) appropriately so that you can build the right command line without having to detect the actual operating system.

EDIT: I don't know why this isn't currently working for you, unless it's because the command line itself is too long.

You could consider putting all the relevant jar files into a single directory, and then using:

java -cp 'somedirectory/*' net.minecraft.client.main.Main

Alterantively, use the extensions mechanism... but that's a last resort, and may cause other issues.

Upvotes: 1

Related Questions