LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 07-20-2013, 09:42 AM   #1
a2326
Member
 
Registered: Oct 2012
Posts: 39

Rep: Reputation: Disabled
Setting up a permanent classpath in Linux Mint Debian


Hello,
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 for any help.

Last edited by a2326; 07-20-2013 at 09:45 AM.
 
Old 07-21-2013, 02:04 AM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
In order to permanently add some path to CLASSPATH variable, just append following line to your ~/.profile or ./bashrc.
Code:
export CLASSPATH="/path/to/antlr:$CLASSPATH"
On the other hand, you can create a soft link of some application to add it to your desktop for ease of access as:
Code:
~$ ln -s </path/to/application> <link-name>
So for example,
~$ ln -s /opt/antlrworks2 ~/Desktop/antlrworks2

Last edited by shivaa; 07-21-2013 at 02:48 AM.
 
1 members found this post helpful.
Old 07-22-2013, 12:29 PM   #3
a2326
Member
 
Registered: Oct 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
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?

Last edited by a2326; 07-22-2013 at 01:37 PM.
 
Old 07-22-2013, 01:48 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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.
 
1 members found this post helpful.
Old 07-22-2013, 01:59 PM   #5
a2326
Member
 
Registered: Oct 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
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?

Last edited by a2326; 07-22-2013 at 02:04 PM.
 
Old 07-23-2013, 12:42 AM   #6
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
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.
 
1 members found this post helpful.
Old 07-23-2013, 05:30 AM   #7
a2326
Member
 
Registered: Oct 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
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]
[input-filename(s)]
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:

# ANTLR
antlr()
{
java org.antlr.v4.Tool # How to correctly pass "$1", "$2" etc. parameters here?
}


# TestRig
grun()
{
java org.antlr.v4.runtime.misc.TestRig # How to correctly pass "$1", "$2" etc. parameters here?
}

Last edited by a2326; 07-23-2013 at 10:55 AM.
 
  


Reply

Tags
alias, antlr, classpath, shortcut


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] setting classpath for mysql java connector in linux sbutt Linux - General 3 09-27-2012 05:27 PM
Setting the CLASSPATH kruger53 Linux - Newbie 2 09-16-2012 05:57 PM
Issues setting keyboard shortcuts on Linux Mint Debian Edition ratman1 Linux - Newbie 1 06-19-2012 11:53 AM
LXer: Linux Mint Xfce - a new spin based on Debian Testing, plus questions answered by Mint guru Cle LXer Syndicated Linux News 0 04-14-2011 05:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration