Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classpath does not work under linux

Anyone have an idea why this command works fine in Windows but in Linux I get a ClassNotFoundException game.ui.Main

java -cp ".;lib/*" game.ui.Main -Xms64m -Xmx128m 

my folder structure looks like this: lib/ - Jars game/ - Class files

This is the latest Java 6.

like image 995
sproketboy Avatar asked Dec 24 '10 21:12

sproketboy


People also ask

How do I find the classpath in Linux?

Setting Java Classpath in UNIX or Linux Now to check the value of Java CLASSPATH in Linux type "echo ${CLASSPATH}" this will print the value of Classpath in the command prompt.


2 Answers

The classpath syntax is OS-dependent. From Wikipedia :

Being closely associated with the file system, the command-line Classpath syntax depends on the operating system. For example:

on all Unix-like operating systems (such as Linux and Mac OS X), the directory structure has a Unix syntax, with separate file paths separated by a colon (":").

on Windows, the directory structure has a Windows syntax, and each file path must be separated by a semicolon (";").

This does not apply when the Classpath is defined in manifest files, where each file path must be separated by a space (" "), regardless of the operating system.

like image 121
peter.murray.rust Avatar answered Oct 04 '22 05:10

peter.murray.rust


Try changing the semi-colon to a colon.

The CLASSPATH separator is platform dependent, and is the same as the character returned by java.io.File.pathSeparatorChar.

like image 31
Mikel Avatar answered Oct 04 '22 07:10

Mikel