How to run a java code from command prompt which is using API? How to run a java code from command prompt which is using API? shell shell

How to run a java code from command prompt which is using API?


The classpath is where Java searches for actual .class files in fodlers by package.
Java does not look at JARs that are inside classpath folders.

You need to put the JAR file itself in the classpath; not the folder that contains it.

(alternatively, you can include folder/*.jar to put every JAR in that folder in the classpath)


The JAR files still need to be on the classpath when running your application, not just when compiling.


When running your Java application, the JVM needs to know about the jars also.

java -cp [path-to-twitter4j-jars] MyCode

Here's a link to java command-line options.