• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How Do I Create This jar File

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Java code makes use of an external jar file which has been included in my classpath but not in the same directory as my project. My program is working perfectly. Now, I want to create a jar file of the project. Do I need to copy the external jar file used by my program into my project directory, or by default it will be included since the classpath has already been set to recognize it?
 
Marshal
Posts: 76829
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't use the usual methods to put jar files inside jar files. there are special tools which can do it, however.
Might be easiest to unzip the jar into the appropriate directory structure, then create a new jar or add the new .class files to your existing .jar. The Java™ Tutorials has a useful section.
 
femi lami
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply, but I think I need to explain better what I am trying to achieve.

My Java code (an expert system) embeds Jess and I need to create a "jar" file of the project. I have imported jess into my Java code using the statement "import jess.*;" and I have also included "jess.jar" in the classpath of the project. Now that I want to create a "jar" file of the application so that it will be runnable on another system having JVM, do I need to still make a jar file of the "jess.jar" file to be included in the project's jar file?

Also, my code makes use of ".clp" file in which the rules for the appliaction are stored. Do I need to include this file as part of the files needed to make the project's jar file.

Lastly, can ".java" file be inluded in the in the jar file or is it only their ".class" files that must be there?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

femi lami wrote:... do I need to still make a jar file of the "jess.jar" file to be included in the project's jar file?


Yes, you will need to distribute "jess.jar" together with your own jar file. What Campbell was explaining is that you cannot include "jess.jar" inside your own jar file with the standard JDK tools. (Java doesn't recognise jar files inside jar files). It has to be a separate jar, or you'd have to use a tool such as One-JAR to pack it all into a single jar.

femi lami wrote:Also, my code makes use of ".clp" file in which the rules for the appliaction are stored. Do I need to include this file as part of the files needed to make the project's jar file.


I don't know, that depends on how Jess works. Look it up in the documentation of Jess.

femi lami wrote:Lastly, can ".java" file be inluded in the in the jar file or is it only their ".class" files that must be there?


You do not need to put the source code ".java" files in the jar, only the compiled ".class" files are necessary to be able to run the program.
 
ice is for people that are not already cool. Chill with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic