Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?
share|improve this question
add comment

2 Answers 2

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
share|improve this answer
add comment

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"

    Don't forget the quotes: they may save you a lot of headaches.

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

     #!/bin/sh
     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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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