0

I'm complete Linux newbie, but still want to provide a simple way for Linux users to start my Java program. Therefore I want to create a shellscript.

I can't test my script so I'll have to ask here if this is working correctly:

#!/bin/bash
java -cp "bin";"extres/junit.jar" data.ProgramOne
exit 0
2
  • 1
    This looks good. You don't need the quotes and the "exit 0" line could be removed. If this is something professional and complex, you should test it on linux (use a virtual machine or a ubuntu distribution that you can test without installation) because the launching of the application isn't generally the biggest porting problem. Commented Mar 14, 2012 at 9:32
  • 2
    Question: Why can't you test your script? Why not download some virtualizer like VirtualBox, install Ubuntu and start testing? It's not like in the old days where you needed a separate machine for such testing scenarios... Commented Mar 14, 2012 at 9:32

3 Answers 3

2

Your mistake is in path delimiter. It is ; on Windows and : on Linux. Moreover you should not wrap each classpath fragment with "". On unix you can escape spaces and other forbidden characters using \. So, I'd re-write the java execution line as:

java -cp bin:extres/junit.jar data.ProgramOne

This will run when you are executing script from your app directory where you have subdirectory bin and extres.

Sign up to request clarification or add additional context in comments.

Comments

1

try this:

java -cp "bin:extres/junit.jar" data.ProgramOne

Comments

1

Java under Unixes uses : as the separator in the classpath, so you'd need (the quotes are not necessary):

#!/bin/bash
java -cp bin:extres/junit.jar data.ProgramOne

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.