I am developing an application which had some dependency and for that i use external tools. One example is that i use putty's commandline tool plink.exe to telnet/ssh remote machine from java program.

Now when i switch to ubuntu, for that there is a utility sshpass that does the same for me. Now the problem is sshpass is not already installed and before it is installed, my program will not work.

In windows, if something is not there, i can package portable executable in my program e.g this plink.exe and use it at run time to do the job. Now in ubuntu, i want to know is there any way that i package .exe like file, which i can simply call with arguments to perform similar tasks??

Basically i want to know is there anyway in ubuntu to run a file without having to install it?? if so how is it possible??

3 Answers 3


In linux, as in windows, you can compile any program with all it's dependencies linked as static files. But the difference that in Linux this is not the usual way to do things.

The Linux-way is to install each program just once, if you need to use shhpass, you shouldn't bundle it with your software, but you should list it as a dependency in your installation package (i.e. deb file for Ubuntu). The package manage will fetch and install when it's installing your program.

There are a couple of reasons for this behavior, from efficiency (use of shared memory) to security (your can ship a security bug with your bundled program). As everything this approach has also its drawbacks, mainly the need for a centralized place to install software, but the important point to your answer is how things are, not how things could be.

The short answer is yes, you can do it, but it will be difficult. You'd be fighting against the culture and design of unix-like OS. You will likely need to compile your own versions of every program that you want to bundle, and most packagers and user are not going to like it.

  • Two pedantic points: 1. while you can link an .so file either statically or dynamically in Linux, you can't statically link .dll nor dynamically link .lib in Windows. :) 2. JohnyDep asks about bundling a third-party executable with his program, so linking, shared memory and other issues are irrelevant here anyway
    – Sergey
    Mar 7, 2012 at 1:05

The idiomatic approach on Ubuntu would be to give out, not your raw program, but a .deb package containing your program and also listing it's dependencies. Then, installing your package will automatically install any missing dependencies (assuming they're available from the standard sources).

There is some documentation here on creating packages.

The alternative, more windows-y (and even somewhat OSX-y) approach, is to bundle statically-linked builds of all your dependencies with your app, and unpack them into a temporary directory from where you run them. You can use a tool like makeself to do this: put all the executables you need, plus your jars and a suitable start script in a directory, and it will do the rest.

  • Agree, sshpass is in Ubuntu repositories so just listing it as a dependency in the .deb's specification is the way to go
    – Sergey
    Mar 7, 2012 at 1:07

Under linux, any file can be executed (so long as you have the privileges). From your java program, you can call any .exe file that you package with it.

You probably need to make sure that the .exe file is executable under linux though. Some if not most of .exe are specific to one operating system. For example, putty's website only provide source code for unix that needs to be compiled into an executable (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html). For windows the executable is already compiled, but probably not runnable under linux/unix.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.