Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is it possible to directly bind all *.class files with the java command?

At the moment I run java-files like:

java myprog args

Is it possible to simple type

myporg args

ok, this is not a very important question, but it would be nice to know.

share|improve this question

closed as off topic by Anwar, Jorge Castro, John S Gruber, jokerdino, Mitch Sep 15 '12 at 5:18

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

2 Answers

up vote 1 down vote accepted
java -cp "/path/to/package/directory/or/directory/with/classes:/another/path" <class_name> [args]

you can use alias

alias <prog_name>='java -cp '"/path"' <class_name>'

and then

<prog_name> [args]
share|improve this answer

you can always set the CLASSPATH variable to the location where all your class files are located or packages are located.

export CLASSPATH=/path/to/package/directory/or/directory/with/classes:/another/path

you can very well add this line in $HOME/.bashrc file.

After that you can just say java myprog args

hope this solves.

share|improve this answer

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