LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 01-30-2007, 08:52 AM   #1
Last Attacker
Member
 
Registered: Jun 2004
Location: South Africa
Distribution: Ubuntu
Posts: 120

Rep: Reputation: 15
Question Inserting ENV. VARS. for all of Linux to use


Hey everyone,
I just would like to know how I can specify environment variables such as JAVA_HOME, update PATH, etc. to be used everywhere in Linux. Currently I specify it in /etc/bash.bashrc (Kubuntu & SuSE). Where can I place it sothat if I want to open a Java app from my desktop, that it will automatically see where the java app is and use that to open up and execute the JAR file?

I hope I am making sence.

Thanks
 
Old 01-30-2007, 10:29 AM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 144Reputation: 144
It varies with the distro, but in general, the system wide environmental variables are normally setup in /etc/profile. However, using /etc/bashrc should accomplish the same thing. Not sure exactly what you are trying to do. To run a .jar file in linux, you would usually run:

$ java -jar app.jar

if you have the java /bin directory in PATH. To have a launch icon from the desktop you could create a bash script(s) that could do that. Post back if you need more details.

Last edited by kilgoretrout; 01-30-2007 at 10:44 AM.
 
Old 02-01-2007, 01:04 AM   #3
Last Attacker
Member
 
Registered: Jun 2004
Location: South Africa
Distribution: Ubuntu
Posts: 120

Original Poster
Rep: Reputation: 15
Thanks kilgoretrout.
The thing is, I did make scripts for the stuff to run but you have to run it from the console in order to pick up the JAVA_HOME var in bash.bashrc and I had to respecify the JAVA_HOME var the whole time in the scripts I'm running.I want to click on a desktop link and let it have access to the JAVA_HOME and new PATH vars without running it from the console. Know what I mean?
 
Old 02-01-2007, 02:57 PM   #4
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,333

Rep: Reputation: 144Reputation: 144
I can illustrate what I'm talking about by example; don't know if this will help. Say you have a java app located in ~/myjava called "coolapp.jar". You can create a bash script to launch it with:

#!/bin/bash
cd ~/myjava
java -jarr coolapp.jar

Lets name the above script "bscoolapp" and make it executable(chmod +x bscoolapp) so it will run. Also, lets put bscoolapp in ~/scripts. Now if you are in ~/scripts, you should be able to launch coolap.jar by running:

$ ./bscoolapp

It should work. Now say you don't want to open a console and cd into ~/scripts every time you want to launch coolapp.jar. Make another script called "do_bscoolapp" like so and put it in your home directory:

#!/bin/bash
cd ~/scripts
./bscoolapp

do "chmod +x do_bscoolapp" to make it executable. Now, open your home directory in konqueror or nautilus. If you doulbe click on do_bscoolap it should launch coolapp.jar. If it works, you can make a shortcut link to it on your desktop and open coolapp.jar by clicking on it.

This is a general technique I've used for many years to create a launch icon on the desktop for applications that can only be launched from the command line.
 
  


Reply

Tags
environment


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Linux Firms Expect to Thrive on VARs' Windows Frustrations LXer Syndicated Linux News 0 07-11-2006 11:21 PM
rbscrobbler not queueing/setting vars, then missing /bin/env kiwibird Linux - Software 1 10-04-2005 10:39 PM
env vars on Slackware 10 lvella Linux - General 1 11-01-2004 05:55 PM
init on boot programs that need env vars The_Spider Linux - General 3 04-29-2004 08:30 AM
bash env vars alias's & .bashrc micxz Linux - General 8 10-08-2003 03:09 PM


All times are GMT -5. The time now is 02:36 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration