Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello,
I have a little Java program that is supposed to be run with a custom amount of memory, to do this I need to create a shell script (I've created a .bat script for windows with no problem). BUT, under Linux my script runs correctly only from the command line - I need to run it at double click as well. The script is supposed to launch a .jar (Java executable) file that's in the same directory. Here's my script (called "start_java"):
It runs successfully from the command line like "./start_java" & Enter.
At double click it wont launch - I think it's about specifying the directory where Java should find the "MyApplication.jar" - here is my problem since I don't know how to do it. From the command line we say "./" to specify the current dir, but using the double click method - the application (java) thinks probably that the current folder is the directory where it is installed.
Hope you got me correctly (the CD $PWD didn't work either).
Please help!
Thanks for the hint. I realized whats the matter: when using double click the "PWD" variable points to my home dir, instead of the directory from where the shell script has been launched - and I have no clue how to fix this.
-from the command line I get a file (thefile.txt) on the desktop containing "/home/brian/Desktop"
-by double clicking the shellscript (from the Desktop as well) I get same file with only "/home/brian"
So, my problem is: How to let the shellscript correctly identify the folder it has been launched from?
Distribution: Distribution: RHEL 5 with Pieces of this and that.
Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700
Rep:
Is the same file being overwritten?
First run it like you say, then delete the thefile.txt and run it again where you want the second time. If it is correct then the second attempt is not forcing and overwrite.
I create the "thefile.txt" from the shell script just to prove that the shellscript behaves differently when it is being launched by double-click or from the command line - both cases have different understanding about the 'current directory' - which is why I can't run the "MyApplication.jar" file double-clicking the launcher ( the "start_java" file ).
Thanks for your time.
I have the same problem, but I do not rely on desktop icons. State the the PATH environment variable or use the full path to the program.
The reason why the script is behaving strangly. All programs that are loaded gets their own seperate environment because Linux is a multi-tasking and a virtual memory OS. To get the script run in the same environment, you type ". [script name]". The dot says in this environment, run this script.
In your script, I suggest adding . on the same line that reads java before java. This will make it easier for Linux to run the program in the same environment as the script is run.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.