Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Building .jar distributions

Reply
Thread Tools

Building .jar distributions

 
 
Tim
Guest
Posts: n/a
 
      12-05-2003
I was trying to learn a bit about JUnit and got it working in a very
basic way through JDeveloper.
So I decided to build a distribution through ant and then try to run the
test I was doing through the DOS prompt.
I kept getting .class not found for various classes in the JUnit jar
file. Of course when I added all of the files from that jar file to the
distribution file, it worked.
What is the best way to determine what classes have to be included in
the distribution or do you just load all of them and save the time of
figuring it out?

 
Reply With Quote
 
 
 
 
Jose Rubio
Guest
Posts: n/a
 
      12-05-2003
Not sure of all the details of what you're doing, but this is what I get
from what you said.

You have a project with a number of Java classes.
You created some test cases to test those Java classes.
You made a jar file that included the real code and the testing code. (Did
you make 1 or did you do a code.jar and a testcases.jar)

IF you want to run the junit test cases from the command line, you will need
to include the code.jar, the testcases.jar (assuming you made two, or just
one distribution.jar), and the junit.jar in the classpath.

How you create your jars for distribution/release should be based on the
architecture of the project. But 3rd party libraries like Junit shouldn't be
included inside a jar you created. They should be kept in a separate jar
like it came in when you downloaded it and just released in your code if
there is any need for it.

BTW. You can use the same ant script to run the test cases. Check the ant
documentation and read on the junit task.

Hope it helps.

Jose


"Tim" <(E-Mail Removed)> wrote in message
news:JoQzb.109016$(E-Mail Removed) ble.rogers.com...
> I was trying to learn a bit about JUnit and got it working in a very
> basic way through JDeveloper.
> So I decided to build a distribution through ant and then try to run the
> test I was doing through the DOS prompt.
> I kept getting .class not found for various classes in the JUnit jar
> file. Of course when I added all of the files from that jar file to the
> distribution file, it worked.
> What is the best way to determine what classes have to be included in
> the distribution or do you just load all of them and save the time of
> figuring it out?
>



 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      12-05-2003
Tim wrote:
> I was trying to learn a bit about JUnit and got it working in a very
> basic way through JDeveloper.
> So I decided to build a distribution through ant and then try to run the
> test I was doing through the DOS prompt.
> I kept getting .class not found for various classes in the JUnit jar
> file. Of course when I added all of the files from that jar file to the
> distribution file, it worked.
> What is the best way to determine what classes have to be included in
> the distribution or do you just load all of them and save the time of
> figuring it out?


If you need a third-party library to run your application, it's typical
to distribute the JAR file from the third-party library separately from
your own code. You almost certainly don't want to pick and choose
pieces of it, as this would break most licensing agreements. So I
definitely wouldn't take bits and pieces of someone else's JAR file and
add them to your own.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      12-05-2003
Thanks for your reply. I've been doing some development work and have,
for the most part, been doing it inside JDeveloper and Homesite (JSP). I
would then move the beans to the correct Tomcat folder and see if it
would work.
Recently, for my own understanding of things, I've decided to try to
create jar files, use ant and use JUnit although they may not be
appropriate for what I was doing before.
So, I'm just trying to tie some of these things together and compile a
simple program and it's JUnit test program, package them in a jar file
and run it from the command line, out of a jar file.
I was also thinking of sending the file to a friend so he could run it
and see what the output of a JUnit test program was because he has been
hearing that people in his company are using it in other groups and I
thought it may be interesting for him to see it in action, albeit in a
simplified example. Of course, if he had to do too much setting up, he
may not be interested.
Anyway, thanks again.

Jose Rubio wrote:
> Not sure of all the details of what you're doing, but this is what I get
> from what you said.
>
> You have a project with a number of Java classes.
> You created some test cases to test those Java classes.
> You made a jar file that included the real code and the testing code. (Did
> you make 1 or did you do a code.jar and a testcases.jar)
>
> IF you want to run the junit test cases from the command line, you will need
> to include the code.jar, the testcases.jar (assuming you made two, or just
> one distribution.jar), and the junit.jar in the classpath.
>
> How you create your jars for distribution/release should be based on the
> architecture of the project. But 3rd party libraries like Junit shouldn't be
> included inside a jar you created. They should be kept in a separate jar
> like it came in when you downloaded it and just released in your code if
> there is any need for it.
>
> BTW. You can use the same ant script to run the test cases. Check the ant
> documentation and read on the junit task.
>
> Hope it helps.
>
> Jose
>
>
> "Tim" <(E-Mail Removed)> wrote in message
> news:JoQzb.109016$(E-Mail Removed) ble.rogers.com...
>
>>I was trying to learn a bit about JUnit and got it working in a very
>>basic way through JDeveloper.
>>So I decided to build a distribution through ant and then try to run the
>>test I was doing through the DOS prompt.
>>I kept getting .class not found for various classes in the JUnit jar
>>file. Of course when I added all of the files from that jar file to the
>>distribution file, it worked.
>>What is the best way to determine what classes have to be included in
>>the distribution or do you just load all of them and save the time of
>>figuring it out?
>>

>
>
>


 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      12-05-2003
Jose Rubio wrote:
> Not sure of all the details of what you're doing, but this is what I get
> from what you said.
>
> You have a project with a number of Java classes.
> You created some test cases to test those Java classes.
> You made a jar file that included the real code and the testing code. (Did
> you make 1 or did you do a code.jar and a testcases.jar)
>
> IF you want to run the junit test cases from the command line, you will need
> to include the code.jar, the testcases.jar (assuming you made two, or just
> one distribution.jar), and the junit.jar in the classpath.

I just tried that and get the NoClassDefFoundError. Do I put the path to
the jar file or include the jar file itself in the classpath?
(ie. C:\JDeveloper\junit or C:\JDeveloper\junit\junit.jar)
>
> How you create your jars for distribution/release should be based on the
> architecture of the project. But 3rd party libraries like Junit shouldn't be
> included inside a jar you created. They should be kept in a separate jar
> like it came in when you downloaded it and just released in your code if
> there is any need for it.
>
> BTW. You can use the same ant script to run the test cases. Check the ant
> documentation and read on the junit task.
>
> Hope it helps.
>
> Jose
>
>
> "Tim" <(E-Mail Removed)> wrote in message
> news:JoQzb.109016$(E-Mail Removed) ble.rogers.com...
>
>>I was trying to learn a bit about JUnit and got it working in a very
>>basic way through JDeveloper.
>>So I decided to build a distribution through ant and then try to run the
>>test I was doing through the DOS prompt.
>>I kept getting .class not found for various classes in the JUnit jar
>>file. Of course when I added all of the files from that jar file to the
>>distribution file, it worked.
>>What is the best way to determine what classes have to be included in
>>the distribution or do you just load all of them and save the time of
>>figuring it out?
>>

>
>
>


 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      12-05-2003
Tim wrote:
> I just tried that and get the NoClassDefFoundError. Do I put the path to
> the jar file or include the jar file itself in the classpath?
> (ie. C:\JDeveloper\junit or C:\JDeveloper\junit\junit.jar)


The latter.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      12-05-2003
OK, I'm still having some problems so maybe I can give some info and you
can see where I'm screwing up. I'm sure it's some relative path problem.

The class that cannot be found is junit/framework/TestCase

My classpath is set in the autoexec.bat file using

SET CLASSPATH=C:\j2sdk1.4.1_06
SET CLASSPATH=%CLASSPATH%;C:\JDeveloper\junitpart.jar

This checks out when I use the set command at the DOS prompt.

The junitpart.jar file exists and contains a file called TestCase.class
and the path is junit\framework\

Any ideas?

Thanks very much
Tim


Chris Smith wrote:
> Tim wrote:
>
>>I just tried that and get the NoClassDefFoundError. Do I put the path to
>>the jar file or include the jar file itself in the classpath?
>>(ie. C:\JDeveloper\junit or C:\JDeveloper\junit\junit.jar)

>
>
> The latter.
>


 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      12-05-2003
Tim wrote:
> OK, I'm still having some problems so maybe I can give some info and you
> can see where I'm screwing up. I'm sure it's some relative path problem.
>
> The class that cannot be found is junit/framework/TestCase
>
> My classpath is set in the autoexec.bat file using
>
> SET CLASSPATH=C:\j2sdk1.4.1_06
> SET CLASSPATH=%CLASSPATH%;C:\JDeveloper\junitpart.jar


Okay, something is fishy here. Why is your JDK install directory (i.e.,
c:\j2sdk1.4.1_06) in your classpath? Also, what about the location of
your actual code? Where is that, since it's not in your classpath
anywhere?

And what's the command you use to run the application?

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      12-05-2003
The code is a jar file that I have copied to, for convienience sake, the
c:\windows directory, since that's what directory I am in when I open
the DOS prompt.
I use the command java -jar MyProjectX.jar while in C:\windows

Should the JDK install directory not be in the classpath? I've been
trying various things over the years and some stuff might be where it
shouldn't be.

Chris Smith wrote:
> Tim wrote:
>
>>OK, I'm still having some problems so maybe I can give some info and you
>>can see where I'm screwing up. I'm sure it's some relative path problem.
>>
>>The class that cannot be found is junit/framework/TestCase
>>
>>My classpath is set in the autoexec.bat file using
>>
>>SET CLASSPATH=C:\j2sdk1.4.1_06
>>SET CLASSPATH=%CLASSPATH%;C:\JDeveloper\junitpart.jar

>
>
> Okay, something is fishy here. Why is your JDK install directory (i.e.,
> c:\j2sdk1.4.1_06) in your classpath? Also, what about the location of
> your actual code? Where is that, since it's not in your classpath
> anywhere?
>
> And what's the command you use to run the application?
>


 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      12-05-2003
Something told me it was being ingnored but I couldn't figure out how or
where to specify it.

Chris Smith wrote:
> Tim wrote:
>
>>The code is a jar file that I have copied to, for convienience sake, the
>>c:\windows directory, since that's what directory I am in when I open
>>the DOS prompt.
>>I use the command java -jar MyProjectX.jar while in C:\windows

>
>
> Ah! That's it. When you use the '-jar' option, the classpath
> environment variable is ignored. Instead, the "Class-path" manifest
> option is used, and all paths there are relative to the location of the
> JAR file. So, you need to place junitpart.jar into the same directory
> as MyProjectX.jar, and then add the following line to the global
> attributes section of your manifest:
>
> Class-Path: junitpart.jar
>
> HTH,
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ANN: PyInstaller 1.0 - build single-file distributions for your Python programs Giovanni Bajo Python 1 09-21-2005 12:03 AM
distutils, install_data and RPM distributions bwooster47@gmail.com Python 0 05-25-2005 03:00 PM
Statistical distributions noshit XML 1 02-07-2005 09:16 PM
2 different Python distributions on same Windows box? David Lees Python 4 09-05-2004 01:38 PM
Begginers questions on different distributions of py Player Python 7 08-25-2004 04:45 PM



Advertisments