2

I ran a java executable file using the following command

java -cp .;aa/bb/cc/dd/Main.jar aa.bb.cc.dd.Main

where aa.bb.cc.dd is the package that has all the .java, .class, and Main.jar files and this package is inside the src folder from where I am running this command. I am getting an error

cannot execute binary file: Exec format error

Can anyone tell me where I am going wrong.

1
  • 4
    Using a semicolon begins a new shell command, so the system is trying to treat the jar as a native executable rather than run it on the jvm. Commented Nov 29, 2014 at 13:04

1 Answer 1

1

Semi-colon in bash is used to separate commands. So in your case

java -cp .;aa/bb/cc/dd/Main.jar aa.bb.cc.dd.Main

java -cp . and aa/bb/cc/dd/Main.jar aa.bb.cc.dd.Main are considered as two separate commands and executed in sequence.

The issue can be fixed by changing the ";" to ":".

The path delimiter for java class path is ":" and not ";".

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.