• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with creating a jar file  RSS feed

 
kishan Jaiswal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the structure of my project

d:\hms-app
   |-src
     |-HMSRunner.java
     |-manifest.txt
   |-bin
     |-HMSRunner.class
   |-lib
     |-hms.jar

this lline is used to compile the program
javac -d ../bin HMSRunner.java

this line is used to execute the HMSRunner
java -classpath ../bin;  com.hms.runner.HMSRunner

/*Thi is the HMS RUNNER* this is the output /

Now while I m creating the jar like this
jar -cvfm HMSRUNNER.jar HMSApp/Manifest.txt com/hms/runner/.class

it only add the Menifest file in meta-inf folder Why ?
and how do i create the jar for this
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding an *  to the class file selection value: *.class
 
kishan Jaiswal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iit gives me again this output
F:\2017-Practicals\Package_work\HMSApp>jar -cvfm HMSRUNNER.jar Manifest.txt com/hms/runner/*.class
com\hms\runner\*.class : no such file or directory
added manifest
 
Norm Radder
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
com/hms/runner/*.class


Is the com folder (at the head of the package name) in the current directory(HMSApp) when the jar command is executed?
That is where the jar command looks for the class files.
 
kishan Jaiswal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
d:\hms-app
   |-src
     |-HMSRunner.java
     |-manifest.txt
   |-bin
     |-com
        |-hms
            |-runner
                 |-HMSRunner.class
this is the structure
 
kishan Jaiswal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manifest-Version: 1.0
Class-Path: ../bin
Main-Class: com.hms.runner.HMSRunner

this is the manifest file i have created
 
Norm Radder
Rancher
Posts: 2240
28
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jar -cvfm HMSRUNNER.jar Manifest.txt com/hms/runner/*.class 

The jar command needs to be issued when the current directory holds the com folder.  From the diagram you posted that looks like the bin folder.
 
kishan Jaiswal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is it mandatory to always create a jar with the root package folder ?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the -C option to change to the root directory
 
kishan Jaiswal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how ?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an example in this tutorial page.

Note '-c' (change directory) is a different option to 'c' (create jar) - yes it is confusing, why they used the same letter for two different things is anyones guess.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!