I am trying to import a package found at /home/jirwin/ptplot5.8/ptolemy/plot/plot.jar. I am using import ptolemy.plot.* and compiling with javac -cp /home/jirwin/ptplot5.8/ptolemy/plot/plot.jar The Class.java. When I run (using java -cp …same… TheClass) I get Error:Could not find or create main class TheClass.
When I take away the -cp from the java call the Could not find or create error goes away…
I know this must be something simple but I can’t figure this out!
If you specify that the classpath is a single jar files — as you seem to be doing — then Java won’t find any classes outside of that jar file. You need your classpath to include both the jar file and the location of your compiled classes. You can use “.” to mean the current directory; i.e.,
Note the “dot colon” prepended to the beginning of the classpath.