• Post Reply Bookmark Topic Watch Topic
  • New Topic

Does classpath work with java ?  RSS feed

 
Vijay Tyagi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

After having used
classpath with javac to compile UseStuff.java
because UseStuff.java needed a class that was in "ws"

ex
cd test
>javac -classpath ws UseStuff.java


Will

>java UseStuff
command work and execute UseStuff

or is some modification needed ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath is not somehow compiled into the class file, and linking to dependencies is not done only at compile time. In other words, at runtime (not only at compile time) you must also set the classpath correctly. So you must also use "-cp ..." with the java command when you run your program.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!