how to run executable in Linux seperate from IDE

Hi, Newbie to Linux but getting comfortable with it.

For kicks I experimented with creating a linux "executable" with Eclipse Oxygen on vmware Ubuntu virtual machine. Nothing to report there it creates a program in the IDE that if you click "run" it does just that,program executes.
However if I copy the program and its dependencies to another directory outside of Eclipse and run it it says the file could not be displayed. Its only a Hello World that just executed successfully in the IDE. When using Eclipse in windows you could run the .exe outside of IDE control as long as you had the DLLs.

So, what am I missing here? Thanks in advance.

exec name: Test Linux on Eclipse VM

same directory:
makefile
objects.mk
sources.mk

If you need the code its just hello world.
Last edited on
Normally, when using Linux, the current directory is not included in the program search tree, for security purposes. You will need to tell the shell that the program is in the current directory by prefacing the program name with "./", ie: ./YourProgramName


Thank you, almost there:

xxxxuser@ubuntu:~/Desktop/test_linux_exe$ ./test_eclipse_on_linux_vm
bash: ./test_eclipse_on_linux_vm: No such file or directory

Ive looked at the apps properties and I don't see a filename extension(not that there should be one), but I can't get my hello world executed. I feel confident its looking in the correct directory.

Last edited on
So is test_eclipse_on_linux_vm in that directory?

Ive looked at the apps properties and I don't see a filename extension(not that there should be one), but I can't get my hello world executed.

Linux doesn't normally have extensions for executable programs.

I feel confident its looking in the correct directory.

Why do you feel confident, did you look at that directory using the ls -l command from the terminal after you have cd'd into that directory?

By the way normally executable files are not kept in the Desktop sub-tree.


Okay I'm going directly to the folder in which it was created by eclipse:

****user@ubuntu:~/eclipse-workspace/test_eclipse_on_linux_vm/Debug$ ls -l
total 120
-rw-r--r-- 1 primeuser primeuser 1388 Mar 22 16:36 makefile
-rw-r--r-- 1 primeuser primeuser 231 Mar 22 16:35 objects.mk
-rw-r--r-- 1 primeuser primeuser 528 Mar 22 16:36 sources.mk
drwxr-xr-x 2 primeuser primeuser 4096 Mar 22 16:36 src
-rwxr-xr-x 1 primeuser primeuser 103072 Mar 22 16:36 test_eclipse_on_linux_vm
primeuser@ubuntu:~/eclipse-workspace/test_eclipse_on_linux_vm/Debug$ test_eclipse_on_linux_vm
test_eclipse_on_linux_vm: command not found
The file is there.
./test_eclipse_on_linux_vm

If you are in ~, then the relative path would be:
eclipse-workspace/test_eclipse_on_linux_vm/Debug/test_eclipse_on_linux_vm

Note that you could be in any directory and write absolute path:
~/eclipse-workspace/test_eclipse_on_linux_vm/Debug/test_eclipse_on_linux_vm
xxxuser@ubuntu:~/eclipse-workspace/test_eclipse_on_linux_vm/Debug$ ./test_eclipse_on_linux_vm
Helloworld!!
Test: 0
Test: 1
Test: 2
Test: 3
Test: 4
Test: 5
Test: 6
Test: 7
Test: 8
Test: 9
Test: 10
Test: 11
Test: 12
Test: 13
Test: 14
Test: 15
Test: 16
Test: 17
Test: 18
Test: 19
Helloworld

Awesome: adding ./ before the file to be executed did it!
I am in that directory and I directly "run" that file....why do I have to use ./?
I am in that directory and I directly "run" that file....why do I have to use ./?


See post# 2 above.
You can also check
echo $PATH

The PATH is a colon-separated list of directories. When you give a "command" without path, the shell will check those directories in order, and if executable file is there, it will be "run".
Thank you.
Might consider adding the current directory to $PATH.
This is safer if you add the current directory to the very end of the path, and safer still if you're on a single-user system.

The worry is that you'll running a program you don't intend. A potential attack is to leave malicious shell scripts named ls or something in the filesystem.
Topic archived. No new replies allowed.