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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am installing a Java program which I have used before on other OSes. It comes with a sh script to start it, and the script is properly identified in the first line as an sh script. The file is quite short, and I have reviewed its contents for accuracy; it seems to be in order.
I assume that the file has to be made executable, and I have done this. For the time being, there are three "x"s in the permissions.
From the command line, in the directory in which the script resides, I try to run the script by typing its name. This gets me an instant retort as follows:
bash: run: command not found
So it is clear that I have misunderstood something somewhere, and done, or omitted to do, something, though I can't see where there was much room for error.
This worked, thank you. It has also left me very confused. Here is the script in its entirety:
java -classpath ./lib/genj.jar genj.app.App
I have found in the meantime some literature on shell scripts. It seems to be telling me that, because of the irst line, I should be able to run it simply by typing its name, as I tried initially (and unsuccessfully. It isn't clear to me why that failed. But there are even more serious confusions which are not touched on by the documentation I have found.
Firstly, the cd line doesn't work at all. It gets an error message saying "no such file or directory". There IS such a directory, and I am running the script from it. Since this is an absolute directory specification, it should leave me just where I am, and make no complaint. But it doesn't matter what directory I specify, I get the same error message.
The jave line gets an error message from the JVM, indicating that it couldn't find genj.app.App.
This line is correct, although I may have abused some Linux rule in writing it exactly so. The lib directory is, as it says, one directory down from the directory I am in (and which the cd line was meant to bring me to if I had started from some other directory). The entry point (genj.app.App) is correct. These two logether work in other OSes, given only the obvious directory changes from system to system, and turning "/" into "\".
While problem of the cd line is script-related, and presumably belongs in this forum, the problem of the java line would probably be better put somewhere else. But I see no forum here or elsewhere where the connection between Linux and Java are addressed. If someone would like to direct me to one, I would be overjoyed and grateful.
I should be able to run it simply by typing its name
I have no idea why, but some scripts (seems to happen moreso with those pointing to /bin/sh) seem to work only if you run "sh <scriptname>"
java -classpath ./lib/genj.jar genj.app.App
isn't the entry point for a jar file contained in it's metafile? you should be able to run a jar with "java -jar /path/to/file.jar" (assuming it's a lone jar file, not dependant on other files in the directory, in which case you will need to be in the directory or set the -classpath switch).
"sh" is an alias for "bash"
wow, I was always under the impression that sh was a totally different enterpreter than bash. what's up with that?
If the shell script isn't executable and . isn't in your $PATH, the shell won't run it automatically.
but it was executable and he typed "./run", so it should have worked, but for some reason it says it couldn't find the enterpreter, even though the path in the shebang is correct. I've encountered this a few times, too. Anyone know why that is?
Several possibilities... one or more of the libs that the shell
is linked against have the wrong permissions.
The partition he's trying to run it from is mounted noexec
(I occasionally do that with home ;} for machines that others
have accounts on when I have to suspect that they may be
installing unwanted software) ...