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 wrote a java program first time on Linux.

This is where my program Test.java is located:

Desktop> APCS (folder)> Chapter5 (folder) > Test.java

I know that to compile I have to type javac Test.java and to run "java Test".

Before that, I have to type cd Desktop, cd APCS, cd Chapter5.

Is there any short way to navigate to Test.java?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Two ways to shorten the time it takes to go down multiple directories:

  • You can go down multiple levels at a time, so you can type cd Desktop/APCS/Chapter5
  • Pressing TAB while typing a directory or file name will automatically complete the rest of the filename for you. So if you are in your home folder and need to cd to your desktop, you can type the first two or three letters of Desktop and press tab to automatically complete it

If you need to compile and run your program a lot, make a shell script on your desktop or somewhere else with:

javac ~/Desktop/APCS/Chapter5/Test.java
java ~/Desktop/APCS/Chapter5/Test
share|improve this answer

You can just use the full path.

Try using these commands:

javac ~/Desktop/APCS/Chapter5/Test.java
java ~/Desktop/APCS/Chapter5/Test

(This assumes the compiled output is in a filename named Test in the same directory)

Ultimately, though, you'll have to retype the path and change it accordingly for when the path changes.

share|improve this answer

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.