• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

How to set classpath for java in Linux

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone say me how to set classpath for java in Linux.
Like in windows, we will go to my computer --> properties(right click) ---> adavnced tab --> Environment variable and setting the classpath.

In Linux how we will be setting?
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
 
Neeba Rebbaca
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before that how can i set path for java?
 
Maneesh Godbole
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which Linux distribution are you using? Different Linux distro's have different preferred ways for installing Java. Google for "<your distro name> Java".

On Ubuntu, the best way to install Sun JDK 6, which will automatically set up your path correctly, is entering the command:
sudo apt-get install sun-java6-jdk
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try like this....
export CLASSPATH=/local/home/soft/bea81sp6/jdk142_11


hope would help

Thanks,
Samir
 
Marshal
Posts: 71620
312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Samir Kureshi wrote:try like this....
export CLASSPATH=/local/home/soft/bea81sp6/jdk142_11

No, that won't help at all. That sets a CLASSPATH to a value which is unnecessary and will lose you access to your local files. It is also specific you your computer, and appears to have some errors, eg missing out .s.

You should never set a permanent CLASSPATH if you can possibly help it. You should use the -cp flags on the "java" and "javac" tools, or put it in the manifest file. For the java and javac tools, look here, then look at the links on the right.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Ubuntu:

open terminal: gedit .bashrc

then append the following to the bottom of the file:

export JAVA_HOME=/<path to jdk>
export PATH=$JAVA_HOME/bin:$PATH


this worked perfectly for me after I downloaded and compiled jdk binaries from sun website. Hope it helps you too.
 
Campbell Ritchie
Marshal
Posts: 71620
312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

There is a better way to install Java on a Debian-based Linux installation, which includes Ubuntu: Jesper Young told us here to use sudo apt-get install sun-java6-jdk which sets the PATH automatically. There is a similar instruction to update it.
An rpm-based Linux installation (eg Suse, Fedora) can use a similar instruction with the rpm tool.

The instructions to use export PATH in the .bashrc file should work for any "bash" terminal; Ubuntu and OpenSUSE and Fedora usually use "bash". You can probably find out which terminal you are using by giving a nonsense instruction to the terminal

campbell@linux-747u:~> which bash
/bin/bash
campbell@linux-747u:~> oeirhglkcjxnvgiud
bash: oeirhglkcjxnvgiud: command not found
campbell@linux-747u:~>

And the name of the shell program appears as part of the error message
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic