Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class Path in linux

 
pratik gaurav
Greenhorn
Posts: 16
Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to set the Classpath in linux ?
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pratik gaurav wrote:How to set the Classpath in linux ?

On Linux, you can set environment variable named CLASSPATH and assign values to it.

However, generally, it is not recommended to set this environment variable unless you need all Java applications on your environment to use specific classes defined in CLASSPATH.

A better option would be to use -cp or -classpath argument while compiling/executing Java codes.

HIH.
 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A sidenote: under Unix including Linux the separator character is :

 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pratik gaurav ,

Would you like to set the class path on an individual user level or on global environment level ( available to all users including root ) ?
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
opent the file /etc/bashrc with your favourite text editor and add the following lines to the top of the file

 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I make wrapping scripts for the different versions like javac15, java16, javap17, and put them on PATH and invoke from them the corresponding java executables with their full path name.
I found this to be a convenient way of peaceful coexistence of different Java versions.

That is an argument against a common global setting.
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan and Saif,

You are simply adding paths of Java utilities (java, javac etc.) to system's PATH variable.

It has nothing to do with CLASSPATH. The class path can be set by ways mentioned in my previous post (defining CLASSPATH variable, or adding -cp or -classpath argument to Java).

HIH.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only use the -cp option (which is the same as the -classpath option).
 
Campbell Ritchie
Sheriff
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always use the -cp option (which is the same as the -classpath option).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic