Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

where & how do you install(add) third party packages???? 2

Status
Not open for further replies.

qb828

Programmer
Sep 27, 2000
98
US
<b>where & how do you install(add) third party packages????</b>

I asked this question a few posts ago.
But I am still having a little hard time.
Can someone direct me to some site where I can read how this?

1) what is the proper place to add the third party package?
- j2sdk1.4.2\jre\lib ???
- j2sdk1.4.2\lib ????

2) after I add the package at j2sdk1.4.2\jre\lib\ext\(new package)

i set the classpath to c:\j2sdk1.4.2\jre\lib\ext;

and path was alread set at c:\j2sdk1.4.2\bin;

when i compile and run the code, i can run file with third party package code only file but no Hello.java file.
I get noclassDefFound error.

when i delete classpth then I can run Hello.java but no third party code.

How do I need to set my path?
is the classpath same as the path?

do i need to set both ?

can you help me?

I can't believe I am having problems with this ?
THanks

QB
 
1) what is the proper place to add the third party package?

You can place it wherever you want. Just set you CLASSPATH variable to point to those packages(Just the directory if you have classes, the jar file itself if it is already packaged)

As for your other questions,

is the classpath same as the path?

PATH and CLASSPATH are not same. PATH is used for locating your executables, this is independent of Java and is used by Windows environment to locate your executables(exe,bat and com files). CLASSPATH is a Java-specific environment variable used by JRE or the compiler to locate the Java classes.

do i need to set both ?
You need to set path to point to your java.exe and javac .exe, (which is already set for you I guess.)
You need to set classpath to point to your jar files and the directories containing the class files.




Ganesh
If you find my post really helpful, please record it by clicking the purple star below.
 
Thanks Ganesh!

Now I am seeing this more clearly.

Another question.
Ok now I set my classpath as c:\jsdk\jre\lib\ext;

and i compile my file like this
javac -classpath c:\jsdk\jre\lib\ext Mytest.java

why do I need to specify the path again above when I set the classpath already?

when I compile without the path it won't do it.
javac -classpath Mytest.java

I don't get this.

THANKS MILLIONS

QB
 
>>why do I need to specify the path again above when I set the classpath already?
I am not sure as to how you set you classpath before running the program. If you don't specify the classpath using -classpath identifier, javac picks up the classpath value from the env variable classpath. You can print the value of this variable any time by typing echo %classpath% at the prompt. May be, this variable is not set to the directory you want and that's why it is not compiling without specifying it explicitly using -classpath identifier. Hope this helps


Ganesh
If you find my post really helpful, please record it by clicking the purple star below.
 
I think you need to append the new jar file to the existing classpath.

If your classpathe is c:\j2skd1.4.2\lib
and you place your new jar file in c:\j2sdk1.4.2\lib\ext\(new jar)

then you would need to add that to your classpath, so that you would have
classpath = c:\j2sdk1.4.2\lib;c:\j2sdk1.4.2\lib\ext\(new jar);

Just a thought.
 
Thanks Egobbitz!

That is what I did exactly on my Home PC and work PC.

I am able to use the package at home like this way,
c:> javac -classpath c:\j2sdk1.4.2\lib\ext\(new jar) test.java

why do I need to use -classpath and path every time I compile?

did i set the classpath already?

another problem is that I did the same on my work pc.
But it can't find the new package I added.

I need someone to explain a little deeper.



QB
 
How are you setting your classpath? What OS are you using?
I am not sure what else to look at there. When you are compiling the program are you compiling from the same directory that the source code is in?

There is one other thing you might want to try, just add a
.; to your classpath, this is for the default package I think.

Let me know what happens.
 
thanks egobbitz.

Now everything works fine.
I don't know what happened before with cmd(DOS) windows.
setting up the classpath works and I don't have to specify the path anymore. just simple javac hello.java will do.
my home and work pcs are fine.
Thanks a lot for your time and help.


QB
 
If you set an environment variable (in Windows or Linux at least) in one shells/command window (or permanently in the environment options dialog or a shellscript) it won't get picked up in any open command windows/shells.
Those will still use the value (if any) set when they were first opened (and any changes made in that shell only).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top