Tuesday, June 12, 2012

Is it possible to run a .bat file in Linux?

No

You will have to change the file to the Linux format, .sh file and then execute it.


Example:

I have a TESTTool folder which contains 2 folders:
1. bin folder with a Tool.jar file &
2. lib folder with Communication.jar file in it


start.bat file looks like this:

cd bin
java -classpath ..\lib\*;Tool.jar testtool.UIFrame


..\lib\* command selects all files in the folder lib.


The folder was added in Ubuntu PC and then provided permission to it.
And the file start.bat was Saved as start.sh file.

But while executing the application, it throws error :

Could not find the Communication class..

Issue 1:
Linux will not select the files in the folder using the command,
..\lib\*;

You have to specify the jar file in the lib folder.

Issue 2
After saving a .bat file to .sh file,
You have to convert the .sh file into linux format using the command
dos2unix start.sh


The start.sh file will look like:

cd bin
java -classpath ../lib/Communication.jar:Tool.jar testtool.UIFrame

No comments:

Post a Comment

Thanks for visiting my Blog....Ur comments n suggestions are most valuable for me...Thanks