how to add things permenantly to the class path?

Greetings

guys, I 'm using morena package(doesnot matter what it is), and when i need to execute my application i have to use things like this:

java -cp examples\examples.jar;javatwain.jar -Xmx128M -Xbootclasspath/p:javatwain_license.jar RunExample

please, is there any simple tutorial to understand this line and what it does exactly, and how can I run my application simply by using (java runexample). I know that things needed to be added to the classpath, and others to variables path; but how, what, and why etc...

simply i cannot understand this all.

[588 byte] By [tleis1a] at [2007-10-1 0:54:22]
# 1
This tells you how to set and use the classpath. http://java.sun.com/j2se/1.4.2/docs/tooldocs/tools.htmlRead Setting the Classpath and How Classes are Found
ChuckBinga at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 2

hello

If you want to add some thing to a CLASSPATH permanently:

On Windows :

** you may right click MyComputer-->Properties-->Advanced-->Environment Variables

** now on User Variables tab you may add a new variable CLASSPATH and its value eg

VARIABLE NAME : CLASSPATH

Variable Value:C:\j2sdk1.4.2\bin;.;

On Unix

** you may add all these in your .profile since thats the on that gets executed on all logins.

hope this helps thanks

Monish

@monish@a at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 3

> On Unix

There is /etc/profile for every user. Check your system.

# /etc/profile for SuSE Linux

#

# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes

# will be lost during system upgrades. Instead use /etc/profile.local for

# your local settings, favourite global aliases, VISUAL and EDITOR

# variables, etc ...

BIJ001a at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 4
Any jar added to the lib/ext directory of your java is automatically loaded.
Peter-Lawreya at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 5
don't put stuff there, it's not meant for it...Of course anything you put anywhere on your machine won't be working if the machine isn't turned on so it's impossible to have a permanent classpath (even the best computer is turned off at some point).
jwentinga at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 6

Thank you guys

Your replies was very useful for me.

I did as Mr. Peter said, and added my jar files to the lib/ext directory. and it worked fine if i use the javac command. But while using NetBeans I am not able to compile. Does NetBeans 3.6 IDE has its own SDK library?! if so where to add the jar files?

tleis1a at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 7
you haven't listened. Do NOT add them to the lib/ext folder but set a classpath to point to them.And read the netbeans documentation on how to set project specific classpaths for your project there.
jwentinga at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 8

Hi

sorry sir jwenting for not listening, but the reason is that I don't know how to set the classpath to point to them.

Is it similar to pointing to the bin directory? i.e. From the path in the enivormental variables. add "C:\j2sdk1.4.2_05\bin;"?

If this is true, Can't I add the libraries to the bin directory? since the classpath is already pointing to this directory?

tleis1a at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 9

you'd do it the same way as changing the path yes.

Except for setting PATH=blahblahblahblah you do CLASSPATH=blahblahblahblah

You cannot just add the locations to your path because the java environment doesn't use the path to determine where classes are to be loaded, it uses the classpath.

jwentinga at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 10
Thank you again sirI am starting to understand some things. but now, I need to know the difference between the path and the class-path in an easy explanations, If you can direct me to some tutorials for dummies I'll be glad :).
tleis1a at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...
# 11

the PATH is used by the operating system to determine where to look for files when no directory is give.

It has nothing at all to do with Java, it just tells the operating system where it can find your java and javac (and others) when you type "java MyClass" (for example) on the command prompt.

Anything not on the path can still be used by the operating system as long as you tell it exactly where to look.

the CLASSPATH is used internally by Java to determine where it can find classes.

It can contain directories and jar-files (PATH can contain only directories). The operating system does nothing with it (except telling java what it is when asked).

Any class that can't be found on the classpath doesn't exist as far as java is concerned.

So they perform similar roles but in a quite different context.

jwentinga at 2007-7-8 1:14:17 > top of Java-index,Administration Tools,Sun Connection...