0

I got following issue when execute a java class with specified classpaths. I search Google many times for the solution but it still don't take effect. Please give me a help, thanks. Here is description of the problem:

When I run this command on Window:

$ java -classpath appfeature.jar;args4j2.0.6.jar mava.AppClassifier class 

AppClassifier just print out string "HelloWorld" to the standard output. But I got the following result :

 $ java -classpath appfeature.jar;args4j2.0.6.jar mava.AppClassifier
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -hotspot      is a synonym for the "server" VM  [deprecated]
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.
./args4j2.0.6.jar: ./args4j2.0.6.jar: cannot execute binary file

Thanks

4
  • Is your mava.AppClassifier present in a .jar file? Commented Jun 19, 2015 at 8:19
  • yes. It's ok with this: $ java -classpath appfeature.jar mava.AppClassifier but fail when add one more additional jar file in classpath. Commented Jun 19, 2015 at 8:45
  • You say this is on windows, not unix or linux? How are you running this command? Commented Jun 19, 2015 at 10:40
  • @Kenster I run it on cmd. Commented Jun 19, 2015 at 12:22

1 Answer 1

2

For anyone having similar issues and coming to this page, you should have a comma (,) between your jars, not a semi-colon (;), so the command should be:

$ java -classpath appfeature.jar,args4j2.0.6.jar mava.AppClassifier class 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.