Question Cannot access jarfile through bash script

epicmo

New member
Aug 16, 2022
4
0
1
System:Linux version 3.10.0-514.26.2.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 15:04:05 UTC 2017
Path:/root
JavaVersion:
java version "17.0.4" 2022-07-19 LTS
Java(TM) SE Runtime Environment (build 17.0.4+11-LTS-179)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.4+11-LTS-179, mixed mode, sharing)
User:Root
Bash script right:755
PaperSpigotVersion:Latest 1.18.2


I put PaperSpigot in "/root/" and try to run it by bash script.
The content of the bash is "Java -Xms1024m -Xms1024m -jar paper.jar" and the name of the bash script is "start.sh".
I use "sh start.sh" to run it and system tells me that Error: Unable to access jarfile /root/test/paper.jar

however , i use command straightly "Java -Xms1024m -Xms1024m -jar paper.jar" and the servercore can run normally.
It seems that i cannot use bash script to run the servercore.

Background:The script could run normally before but i cannot work as before after the server exited unexpectedly because of players.And I have tried rename the paper.jar or move it to another play but i cannot solve this problem.
 

Tacklezaza

New member
Aug 14, 2022
15
0
1
Hello,

How people on earth use root user to execute program, don't do that always create user and run software with in /home/your_user.
Move everything to /home/ directory then we talk
 

Tacklezaza

New member
Aug 14, 2022
15
0
1
Hi,

Try this. create directory name "paper" by
Bash:
mkdir paper
and "cd" to that directory
Bash:
cd paper

Download paper server jar file. name rename it to paper.jar

then run it
Bash:
java -Xmx2g -jar paper.jar

Is it working?. If not working what does it said in terminal, post your output in this thread
 
Last edited:

epicmo

New member
Aug 16, 2022
4
0
1
Hi,

Try this. create directory name "paper" by [CODE =bash]mkdir paper[/CODE]
and "cd" to that directory [CODE =bash]cd paper[/CODE]

Download paper server jar file. name rename it to paper.jar

then run it
Bash:
java -Xmx2g -jar paper.jar

Is it working?. If not working what does it said in terminal, post your output in this thread
Thank you but it doesn't work.
And I had tried rename the jarfile , move jarfile to another place and change jarfile version.
It seemed that this jarfile can only be ran by command but not bash script.
It is so strang.
 

Tacklezaza

New member
Aug 14, 2022
15
0
1
What is in your script start.sh?

Bash:
#!/bin/bash
java -Xmx2g -jar paper.jar

And execute by
Bash:
bash start.sh
Dont forget to chmod your start.sh to make it executeable
Bash:
chmod +x start.sh

Does it working? if not
What Linux OS did you using? Centos? which version? (7, 8 steam, 9 steam?)

And maybe try with full path, something like this....
Bash:
#!/bin/bash
java -Xmx2g -jar /home/your_user/paper/paper.jar

#- Or maybe this
java -Xmx2g -jar ./paper.jar
 

epicmo

New member
Aug 16, 2022
4
0
1
What is in your script start.sh?

Bash:
#!/bin/bash
java -Xmx2g -jar paper.jar

And execute by
Bash:
bash start.sh
Dont forget to chmod your start.sh to make it executeable
Bash:
chmod +x start.sh

Does it working? if not
What Linux OS did you using? Centos? which version? (7, 8 steam, 9 steam?)

And maybe try with full path, something like this....
Bash:
#!/bin/bash
java -Xmx2g -jar /home/your_user/paper/paper.jar

#- Or maybe this
java -Xmx2g -jar ./paper.jar
I have metioned in my first post where you maybe get some details.
Script:Java -Xms1024m -Xms1024m -jar paper.jar
execute by:sh ./start.sh or bash ./start.sh
And I have given the bash right 755 which means it has "x" right.
The Linux version is redhat.
And I have tried full path or rename the paper jarfile or move it to another place. However , nothing has happened.
I think that Java or system may have some trouble but I cannot solve it.
 

Tacklezaza

New member
Aug 14, 2022
15
0
1
That very weird, I'm using Linux more than 15 year, I'm never have a problem like that
Sorry I can't help 😑

Maybe the last thing you can try.... If it not work then don't forget to restore it back!
Try to disable SELinux, This thing can cause a problem sometime when doing some script or automation things

Edit the /etc/selinux/config file as follows

Change this
SELINUX=enforcing

To this

SELINUX=disabled

Then reboot the system
Good luck!