Java classpath with and without a colon ":"

I am learning Java, and I have a quirk, and I think that only someone with experience can answer (I went through the whole list of similar problems on SO).

When run from the command line after compiling in Eclipse, this works

java -classpath : test.class 

and it is not

 java test.class 

and without specifying a directory

 java -classpath bin test.class 

but with a colon DOES

 java -classpath bin: test.class 

I realized that

  • Java checked the current default working directory.
  • The colon was used only if you indicated more than one path where I have only one.
+4
source share
1 answer

You want to run "java test", not "java test.class"

Greetings

+1
source

Source: https://habr.com/ru/post/1393683/


All Articles