I save a file Logisim2.7.1.jar in my directory at /home/danny/Application. Whenever I want to run this file in terminal, i have to type these following line in terminal:

 cd /home/danny/Application
 java -jar logisim.2.7.1.jar

Then the file will execute.

My question is: instead of typing all that command line in terminal, can I just type logisim in my terminal and the file will execute?

I did this before by doing the following steps which im not sure, if you know, please correct me:

  1. Create a folder called "bin" in home directories.
  2. Create a text file inside the bin folder, and add this line java -jar logisim.2.7.1.jar then save it as logisim.txt
  3. I then edit the .bashrc file by adding this line at the bottom:
    PATH=$PATH: home/familypc/bin/
  4. After that I did something with chmod in my command line which i forgot to make terminal to look in the new bin directories. any helps?

What you want to do is probably this:

  1. mkdir ~/.local/bin

    This will create the directory .local/bin inside your home, which is sightly better than just bin (although bin is OK, too).

  2. Add to your .bashrc the line PATH="$PATH:$HOME/.local/bin"

  3. Create the file ~/.local/bin/logisim and write something like this:

    java -jar $HOME/full/path/to/logisim.2.7.1.jar

    Note: the file is called logisim, without the .txt extension. Also note that you need to specify the full path to the jar file.

  4. chmod +x ~/.local/bin/logisim

Now you can restart your shell and enjoy.


You could simply create and alias by adding the following line to your .bashrc:

alias logisim='java -jar /home/danny/Applications/logisim.2.7.1.jar'

...then reload .bashrc with

source ~/.bashrc

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.