BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Finding classes in external jar files

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Deployment
View previous topic :: View next topic  
Author Message
Zvonimir Ordanic
Guest





PostPosted: Mon Oct 27, 2003 9:54 pm    Post subject: Finding classes in external jar files Reply with quote



When I build a project jar file, usually that jar file does not contain the
JRE classes. When I execute the jar file, the jar file seems to find JRE
classes if they have been previously installed in the system.
However, when I try to find classes that happen to reside in other jar
files, which happened to be listed in the CLASSPATH, it seems that the
class loader should find those classes. However, I get
ClassNotFoundException instead.

I can include the library (jar) in my project and than everything is fine.
But I do not want to do that. I do not want to package the other jar file
with mine. I would like for a class loader to find the other classes in the
external jar files as listed in CLASSPATH statement.

Is this possible? Any ideas how could this be accomplished.
Thanks,
Z.


Back to top
Paul Furbacher [TeamB]
Guest





PostPosted: Thu Oct 30, 2003 9:51 pm    Post subject: Re: Finding classes in external jar files Reply with quote



In <3f9d9425$2 (AT) newsgroups (DOT) borland.com> Zvonimir Ordanic wrote:

Quote:
When I build a project jar file, usually that jar file does not
contain the JRE classes. When I execute the jar file, the jar file
seems to find JRE classes if they have been previously installed in
the system. However, when I try to find classes that happen to reside
in other jar files, which happened to be listed in the CLASSPATH, it
seems that the class loader should find those classes. However, I get
ClassNotFoundException instead.

I can include the library (jar) in my project and than everything is
fine. But I do not want to do that. I do not want to package the
other jar file with mine. I would like for a class loader to find the
other classes in the external jar files as listed in CLASSPATH
statement.

I'm guessing in a console window, you are doing this

% java -cp.;some.jar;other.jar org.myOrg.MyClass

where the list for -cp includes _all_ the required JARs, or

% set CLASSPATH=some.jar;other.jar
% java -cp.;%CLASSPATH% org.myOrg.MyClass

where you define the classpath in your script/console session.

Are you saying that neither of these approaches work,
and result in ClassNotFoundExceptions? If so, you
aren't including all the required JARs on your class
path. Be sure to print/echo the classpath to the terminal/
console before you call "java ...." and check to see
that all required JARs are there.

Or, are you suggesting that you don't want to add
any libraries to the "Required Libraries" tab of
your Project Properties, but hope that JBuilder
will use your system-wide classpath definition?

If it's the latter, you have to read the on-line
Help docs again. They clearly state that JBuilder
does not use any external classpath when running
or debugging your application. It assembles the
classpath precisely from those libraries described
in the "Required Libraries" tab.


Finally, one other piece of info:

One of the easiest ways to get a valid command-line
from an application which runs in JBuilder is to
go to the Message Pane of the running application,
and copy the first line. Put that into a .bat or
sh file and you have an almost 100% guarantee that
the script will successfully launch your program
in a console/terminal window outside JBuilder.


Paul Furbacher [TeamB]

Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.

Back to top
Zvonimir Ordanic
Guest





PostPosted: Fri Oct 31, 2003 1:30 am    Post subject: Re: Finding classes in external jar files Reply with quote



First of all thank you for responding to my question.
All I was doing is creating the Native Executable, where in the
Dependencies tab (within the properties) I have selected option to "Never
include any classes or resources". The reason I did not select anything is
that I have expected that the java Class Loader will find the correct
library from the environment's classpath.

After the compile I have simply clicked on the resulting exe. Since the
exe is actually a wrapper, I have expected that it will find the dependent
library classes from the environment's classpath. In other words, I have not
started my program with
java -cp .... org.MyOrg.MyClass
java -classpath .... org.myOrg.myClass

When I run the program from the JB IDE, the program runs fine, but this is
because I have defined in the project's path the dependent library, and the
IDE issues command
java -cp dependent.jar;..... org.MyOrg.MyClass

But, I think you have answered my question, although I do not like the
answer. I missed the point that JBuilder does not use any external
classpath when running an application.
I am looking now at possibility of using the .config files, but I have
problems there also. I have already posted another question on that topic.
Thanks again for your help.
Z.
"Paul Furbacher [TeamB]" <pfurbacher (AT) mac (DOT) com> wrote

Quote:
In <3f9d9425$2 (AT) newsgroups (DOT) borland.com> Zvonimir Ordanic wrote:

When I build a project jar file, usually that jar file does not
contain the JRE classes. When I execute the jar file, the jar file
seems to find JRE classes if they have been previously installed in
the system. However, when I try to find classes that happen to reside
in other jar files, which happened to be listed in the CLASSPATH, it
seems that the class loader should find those classes. However, I get
ClassNotFoundException instead.

I can include the library (jar) in my project and than everything is
fine. But I do not want to do that. I do not want to package the
other jar file with mine. I would like for a class loader to find the
other classes in the external jar files as listed in CLASSPATH
statement.

I'm guessing in a console window, you are doing this

% java -cp.;some.jar;other.jar org.myOrg.MyClass

where the list for -cp includes _all_ the required JARs, or

% set CLASSPATH=some.jar;other.jar
% java -cp.;%CLASSPATH% org.myOrg.MyClass

where you define the classpath in your script/console session.

Are you saying that neither of these approaches work,
and result in ClassNotFoundExceptions? If so, you
aren't including all the required JARs on your class
path. Be sure to print/echo the classpath to the terminal/
console before you call "java ...." and check to see
that all required JARs are there.

Or, are you suggesting that you don't want to add
any libraries to the "Required Libraries" tab of
your Project Properties, but hope that JBuilder
will use your system-wide classpath definition?

If it's the latter, you have to read the on-line
Help docs again. They clearly state that JBuilder
does not use any external classpath when running
or debugging your application. It assembles the
classpath precisely from those libraries described
in the "Required Libraries" tab.


Finally, one other piece of info:

One of the easiest ways to get a valid command-line
from an application which runs in JBuilder is to
go to the Message Pane of the running application,
and copy the first line. Put that into a .bat or
sh file and you have an almost 100% guarantee that
the script will successfully launch your program
in a console/terminal window outside JBuilder.


Paul Furbacher [TeamB]

Save time, search the archives:
http://info.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
http://www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder Deployment All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.