I have made jar file for my application. One of the class of my application uses BouncyCastleProvider class of BC jar.
I have created one folder "lib" in the same parent folder where my application jar is residing.
I have changed my machine CLASSPATH to point to this new lib folder. But when I run my application it gives me classnotfound exception.
But if I copy this BC jar file to my jre/lib/ext then everything works fine.
Can anybody tell me what I need to do to access BC jar file from my lib directory?
Thanks in Advance,
Jenish
Your JAR file must have its MANIFEST.MF file set to declare the classpath for the JAR.#
Extract from the Sun Tutorial below, in your case you just need to make the Class-Path directive point to your lib directory, presumably
Class-Path: lib/BouncyCastle.jar
We want to load classes in MyUtils.jar
into the class path for use in
MyJar.jar. These two JAR files are in
the same directory.
We first create a text file named
Manifest.txt with the following
contents:
Class-Path: MyUtils.jar
Warning : The text file must end with a new line or carriage return.
The last line will not be parsed
properly if it does not end with a new
line or carriage return.
We then create a JAR file named
MyJar.jar by entering the following
command:
jar cfm MyJar.jar Manifest.txt MyPackage/*.class
This creates the JAR file with a
manifest with the following contents:
Manifest-Version: 1.0
Class-Path: MyUtils.jar
Created-By: 1.6.0 (Sun Microsystems Inc.)
The classes in MyUtils.jar are now
loaded into the class path when you
run MyJar.jar.
Related
To do a test, I have to add a jar file into a Java war file I've created with Maven. The war file works itself fine.
To insert my lz4-java-1.6.0.jar into application-metier-et-gestion.war on internal zip folder /WEB-INF/lib, I use this command :
zip -b WEB-INF/lib application-metier-et-gestion.war lz4-java-1.6.0.jar
But I receive that error message :
zip warning: expected 354 entries but found 84
zip error: Zip file structure invalid (application-metier-et-gestion.war)
I can do and redo mvn clean install it will always create a runnable war that seems perfect to me, but that zip declares invalid. Who is wrong ?
I case zip would be going wrong, what is the workaround to do what I want ? Is there a way through another tool ? tar ?
I case Maven would be going wrong and create a bad war file each time, how to detect the part it is creating wrongly ?
right click the war file ,rename the file extension war into zip
example :
test.war -> test.zip
As far as I can see you tried to add an additional library to the archive.
JAR files and WAR files are plain ZIP files. There is only one rule you have to obey, library files must not be compressed.
If you want to add JAR files to a JAR or WAR file, disable compression for the specific file to be added.
I got a jar file, and I know a class name in it for sure.
I need to know, in case this class file is in folder inside that jar, a command #Unix, in which I can see the full path of that class file where in that jar.
Thanks.
Try doing
jar tf TicTacToe.jar
For additional information you can do
jar tvf TicTacToe.jar
I have properties directory on my linux machine under:
/home/webserver/tomcat6/properties
and in it I have:
js.db.properties
js.ldap.properties
Servlet calling these property files is under:
/home/webserver/tomcat6/webapps/myapp/WEB-INF/classes/myServlet.class
I am trying to go 4 directories up to get to properties files.
FileInputStream ldapfis = new FileInputStream("../../../../properties/js.ldap.properties");
I am getting:
Encountered following error: java.io.FileNotFoundException: ../../../../properties/js.ldap.properties (No such file or directory)
Does anyone know how to do this?
When you type ls foo, it doesn't search the file 'foo' in the same directory as the executable or dynamic library which implements the ls command. It searches it in the current directory, i.e. the directory from which you launched the ls command. The same goes for Java.
new FileInputStream("../../../../properties/js.ldap.properties")will search for the file by starting at the directory from which the java command, used to start Tomcat, was executed.
The location of the class containing this line of code is completely irrelevant. BTW, most of the time, the .class file is in a jar or war file, or both.
Please, provide simplest way to convert .groovy-script to executable file .exe for windows-platform or .jar, for using on multiply platforms.
Thanks
Jar
This project is a simple card game, written in Groovy. It is uses a Gradle script to build a zip file that can be executed like so:
unzip warO.zip
java -jar warO.jar
See this segment of the build.gradle file to see how the manifest is specified for the jar (i.e. the classpath, main class entry point, etc):
jar.archiveName 'warO.jar'
jar.manifest {
attributes 'Main-Class' : 'net.codetojoy.waro.Main'
attributes 'Class-Path' : 'jars/groovy-all-1.6.4.jar jars/guava-collections-r03.jar jars/guava-base-r03.jar'
}
Exe
For an exe, consider a tool such as JWrapper.
I am trying to create an aar file using OSX 10.7.5 (as a part of this tutorial). To generate the .aar, I navigate to the directory holding my webservice in my eclipse workspace and type
jar cvf FirstWebService.aar ./*
This is the command that Apache says to use to generate the aar in their Code Listing 9 from the apache axis 2 documentation.
The command creates an.aar -- but something is wrong with the process that I am using to create the .aar because when I go to load the .aar file into tomcat's /webapps I get an .xml/services not found error.
I am not sure what to do to fix this error. If I search my computer's file system for the services.xml file, I can find it in /path to eclipse workspace/workspace/MyFirstWebService/WebContent/WEB-INF/services/FirstWebService/META-INF
but I am not sure if this file is supposed to be rolled in to the .aar file somehow or if I can just manually plunk this file somewhere into the apache directory structure to get the thing to run.
Note: I do not think I am manually unzipping or unpacking the aar like in this question. Axis2 web service error: services.xml not found I am just running the command listed above from the apache documentation.
Here is the .aar file
note I am using all of the same versions of the software as in the tutorial -- but I am using OSX 10.7.5 where they use windows in the tutorial. Accordingly, I have changed the make-aar command for windows shown in the tutorial (jar cvf FirstWebService.aar com META-INF) into the one shown above. If I just try to run the command from the tutorial jar cvf FirstWebService.aar com META-INF I get the same xml/services not found error. It gives this output in the terminal...
com: no such file or directory
META-INF: no such file or directory
added manifest
I found the issue. When you type the command to create the aar file you have to be in the directory .../EclipseWorkspace/EclipseProjectName/WebContent/WEB-INF/services. This directory contains /META-INF/services.xml. The process that makes the .aar file must be looking in this folder.