Setting up a permanent classpath in Linux Mint Debian
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Setting up a permanent classpath in Linux Mint Debian
I would like to create a permanent alias for ANTLR (located in /usr/lib), but I don't know how to do that, because I don't understand which of those files (/etc/profile, etc/bash.bashrc....) I have to edit and I'm also a bit afraid that I could mess up my system when I edit files just by trial-and-error.
I have also one further question: I would like to append ANTLRWorks which is a Java application to the main menu and connect it to a GUI symbol. Right now it is installed in /opt/antlrworks2, but I'm not sure if this an appropriate location.
Thanks, but "export" doesn't add files permanently to the classpath. I have some further questions:
1. When I add a file to the classpath I store a string in a file, but where can this file be found?
2. The file that I added to the classpath is a .jar containing some classes. From this file I want to call different classes with commands like java org.antlr.v4.Tool or java org.antlr.v4.runtime.misc.TestRig. How could I create permanent aliases for those commands and in which file are those aliases stored?
Which file you want to find.. File in which your .jar file is located or the file in which your want to add the path? Well, you can add the mentioned command in /home/<username>/.bashrc or /home/<username>/.profile. In same fashion you can add alias of any command in the same files.
When I enter export CLASSPATH="/path/to/antlr:$CLASSPATH" the classpath info is stored somewhere, but where? I don't know that.
I stored my aliases and the export command in /home/<username>/.bashrc which works, but it only works after the bash has started.
Is the difference between /home/<username>/.profile and /home/<username>/.bashrc that the former is more general, loaded at system start and can be used for any application while the latter is loaded after the bash has been started and can be only used by the bash?
If I should be wrong: Where should I store path variables that should be loaded at system start and used by other applications and not only by the bash?
Well, there're two kind of .profile files. First is in your home directory i.e. inside /home/username, and second one is system wide i.e. /etc/profile. If you will add/append any export or alias command in your personal .profile file, then those commands will work only for your session, that is, they will work only when you will login into your session and when your /home/username/.profile file will be sourced.
Further, just running the command in your terminal will work only in your current session. And after closing the session, you will again need to run them. So if you want to make these commands permanant and use them system wide, then better to add/append these commands in system's /etc/profile file.
Thank you. To make it short all environment variables that should have only user-wide scope should be placed in a file that starts with ~/ like ~/.bashrc, ~/.profile or ~/.bash_profile.
System-wide environment variables should be placed in /etc/profile or /etc/bashrc. There is also the /etc/profile.d directory, which can be used for startup scripts.
Files like /etc/profile and ~/.bash_profile are read after login at startup (interactive login shell), others like ~/.bashrc are read when the terminal is started (interactive non-login shell).
Is this right so far?
I noticed that setting aliases in /etc/profile doesn't work. Why?
Aliases seem not to be a good solution, because I need to pass parameters, hence I must use functions. The functions are called, but for some reason the parameter mapping doesn't work.
The first programm (mapped be function antlr) has those parameters:
ANTLR Parser Generator Version 4.1
-o ___ specify output directory where all output is generated
-lib ___ specify location of grammars, tokens files
-atn generate rule augmented transition network diagrams
-encoding ___ specify grammar file encoding; e.g., euc-jp
-message-format ___ specify output style for messages in antlr, gnu, vs2005
-long-messages show exception details when available for errors and warnings
-listener generate parse tree listener (default)
-no-listener don't generate parse tree listener
-visitor generate parse tree visitor
-no-visitor don't generate parse tree visitor (default)
-package ___ specify a package/namespace for the generated code
-depend generate file dependencies
-D<option>=value set/override a grammar-level option
-Werror treat warnings as errors
-XdbgST launch StringTemplate visualizer on generated code
-XdbgSTWait wait for STViz to close before continuing
-Xforce-atn use the ATN simulator for all predictions
-Xlog dump lots of logging info to antlr-timestamp.log
The 2nd program has those parameters:
java org.antlr.v4.runtime.misc.TestRig GrammarName startRuleName
[-tokens] [-tree] [-gui] [-ps file.ps] [-encoding encodingname]
[-trace] [-diagnostics] [-SLL]
Use startRuleName='tokens' if GrammarName is a lexer grammar.
Omitting input-filename makes rig read from stdin.
My functions are located in /etc/bash.bashrc:
java org.antlr.v4.Tool # How to correctly pass "$1", "$2" etc. parameters here?
java org.antlr.v4.runtime.misc.TestRig # How to correctly pass "$1", "$2" etc. parameters here?