简体   繁体   中英

How to provide path to a class in java in command line?

Basically I would like to run a main function in java using command line, the name of this class is called SingleProteinModel.java. Its path is in ~/Documents/conifer/ctmc, I am not sure how to provide the path of this class.

I need to work under conifer directory in command line.

I am wondering what command should I type, something like below:

/user/bin/java ~/Documents/conifer/ctmc/SingleProteinModel.java 

The current error is

at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: /Users/Documents/conifer/ctmc/SingleProteinModel-inputFile. Program will exit.

I am not sure the path. I don't know how to provide path to this class. I appreciate your help!!!!

You have to specify the classpath, try:

java ~/Documents/conifer/ctmc/SingleProteinModel.java  -classpath /path/to/Users/

The path should be the path to the directory Users wich is the base of the package of the missing class wich is in a .class file (I mean, you have to point to the bytecode, not to the source code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM