When i try to execute to execute this line
bash -x ExecutionAuto.bat
I get an error from my Lib folder saying that one of the jars isnt working properly.
../Demo_Automatisation/lib/SparseBitSet-1.2.jar: line 1: $'PK\003\004': command not found
../Demo_Automatisation/lib/SparseBitSet-1.2.jar: line 2: $'ؔ\220L': command not found
../Demo_Automatisation/lib/SparseBitSet-1.2.jar: line 8: syntax error near unexpected token `)'
��������0 6&»���2<��߽�{�i'���arseBitSet-1.2.jar: line 8: `��6)Ѐ*u)�����RP �rN-p�đ�
�{�eB�M}i��Qa0�{}/�aHU�
'���xQXk)�Ћ.'?l3����A�I�|��0AİV���v�)s ?���5N���V��v��hH�;"���~Gt D��}|ȣ^�`�ܨ"r��d���}7��0t)y���{�W���
java org.testng.TestNG ../Demo_Automatisation/testng.xml
Error: Could not find or load main class org.testng.TestNG
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
I dont know if there is a probleme with the jar files since it works fine in Windows but in linux it doesnt work.
This is my .sh file:
export projectLocation=../Demo_Automatisation
cd $projectLocation
export CLASSPATH=$projectLocation/bin;$projectLocation/lib/*
java org.testng.TestNG $projectLocation/testng.xml
I just coppied what i found on the internet since i had a .bat file at first since i was using Windows does transferring from Windows to linux requieres that i do something to my jar files ?
CodePudding user response:
The issue is that the ;
in your classpath definition actually separates two commands so the $projectLocation/lib/*
is interpreted as a new command, expands to the name of the jar file and the shell tries to execute the jar file as a shell script (which fails miserably). On Linux the separator for classpaths is :
and not ;
(almost certainly for exactly this reason).
In other words: instead of
export CLASSPATH=$projectLocation/bin;$projectLocation/lib/*
you need
export CLASSPATH=$projectLocation/bin:$projectLocation/lib/*
As a bonus suggestion: the /*
in the CLASSPATH
should be interpreted by Java and not the shell, so it's better to actually quote the value:
export CLASSPATH="$projectLocation/bin:$projectLocation/lib/*"
CodePudding user response:
The projectLocation
is a relative path which you reuse after changing the working directory. Try to use an absolute path, maybe it gets fixed that way.