SCJP: Classpath and Jar #Java Short Notes #SCJP #Blog

Java certification exams like SCJP test your knowledge about java classpath. Check here for an excellent resource on the topic .

System classpath

We can specify classpath in the command line or make use of a `system' class path. The IDEs have their own way of maintaining class paths. System class paths will be used by both the Java compiler and the JVM in the absence of specific instructions.

Set Linux System Classpath:
CLASSPATH=/myclasses/myclasses.jar;export CLASSPATH

Windows:
set CLASSPATH=c:myclassesmyclasses.jar

For permanent result, in Linux, put the commands in the file .bashrc in your home directory. On Windows 2000/NT, set it from `Control Panel', System, Environment Variables.

You can also specify .jar files full of your required classes in your classpath.

CLASSPATH=/usr/j2ee/j2ee.jar:.;export CLASSPATH

where the `.' indicates `current directory'.

From command line, if you want to add more paths to the classpath use:

Linux:javac -classpath $CLASSPATH:dir1:dir2 ...

Windows:javac -classpath %CLASSPATH%;dir1:dir2 ...

if you have spaces in your path use double quote to concatenate words.

Also check this resource

From: http://sitestree.com/?p=4849
Categories:Java Short Notes, SCJP, Blog
Tags:
Post Data:2013-06-05 14:27:56

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Leave a Reply