2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Javaのクラスパス(classpath)の設定方法

Posted at

クラスパスを設定する方法は下記の3つあります。

1 コマンドラインで指定する

java -classpath C:\program

';'(セミコロン)区切りで複数のクラスパスを設定できます。
javaコマンドでは'-classpath'を'-cp'に省略可能です。

java -cp C:\program1;C:\program2

2 OSの環境変数に設定する

Windows
set CLASSPATH=C:\program1;C:\program2
macOS
export CLASSPATH=~/program1;~/program2
linux
setenv CLASSPATH=/home/program

3 デフォルト(指定しない場合)

カレントディレクトリになります。
'C:\program\sample'で実行した場合は'C:\program\sample'がクラスパスになります。

参考文献

2
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?