Linux - GeneralThis 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
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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 09:44 AM.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.