Jar file vs classes
Hi,
i am encountering a strange problem.
I am trying to run quartz (java application) on oc4j server.
When i have all the quartz classes in web-inf/classes folder, the application runs fine, but the moment i make a jar out of all classes and put the jar file in web-inf/lib folder, the application gives me a null pointer exception saying it is not able to set properties from an external properties file.This properties file is located in web-inf/classes folder.
Any help on sorting this out is welcome.
Regards
Ashish
The are 2 possible ideas :
1. If processing your external properties file is not hardcoded in .jar, so point
classpath to the properties in META-INF/MANIFEST.MF file, example :
Class-Path: .
dot (.) point to the location WEB-INF/classes and you can test it easily with such code :
Properties config = new Properties() ;
InputStream is = getClass().getClassLoader().getResourceAsStream("config.properties") ;
if ( is == null ) {
System.err.println("Could not load config.properties") ;
} else {
config.load(is) ;
Manifest file could be easily generated using ant.
2. If it will not help, you should put your properties file inside .jar , but I suppose
first solution will rock.
Similar Messages
-
How to add jar file in class path ?
Hello,
how can I add jar file in system class path.
I am using Linux and installed java.
Now I am creating one java package and working programs.
I want to add commons-net-2.0.jar jar file into class path.
how can I add in linux systems.
Thank you.the same way you add anything else to the classpath.
-
DrClap, schapel, jschell whats better architecture jar files or class files
What would be a better architecture for deployment. Jar files or class files. We were recently having a debate at work as to generate installation scripts that put jar files on the system where the app is being installed or to make the script generate class files at the desired location.
It would be good to know as to what you ppl think and what are the pros and cons of both.
Some claimed with class files it would be easier to put in patches later on and I kinda agree with that. However your thoughts would be appreciated.
Come on DrClap, schapel, jschell, jsalonen....... I am a fan of yours alreadyThis, of course, is why topics shouldn't be addressed to individuals - they are likely to never see it. Today is the first time I have seen this, and that is due solely to a search that I was running.
Why would you use one over the other?
----Distribution costs
It takes more time to send a bunch of class files down the wire than a single jar file. However, it takes more time to send a jar than a single class file. So there is a delicate trade off in a web application where one is using java. If you send the jar every time it is modified the entire jar must be moved. Class files take less time, but all of them must be moved for a new person.
So in this case if you have a fixed based of users (internal use), and a majority of the files do not change then class files are better. If the user base is transitory and large (external use) then a jar file is probably better.
----Usage:
You can use reflection to dynamically add functionality to an application. If you use a jar file then the application must be restarted for the changes to take effect. If you use class files then the application does not have to be restarted. Obviously the second only works if you have some way to dynamically notify the application that new classes are available - like a database.
This becomes very relevant if you do not want to restart the application and you do not have a distributed application base in place.
Also the older classes, even if not used, are still loaded in the application unless it is restarted (presuming a class loader is not used.) Most of the time this does not make difference.
Since in the above it is likely that there is not a large distribution problem, when the usage is a concern then the best strategy is as class files. They allow the most flexibility and there is unlikely to be any concern at all how it is packaged.
-------Misc
Speed. Someone suggested speed. Guessing I would say that the jar file is going to be faster. Once the Sun jvm gets the file it doesn't let go. And as pointed out opening files is rather costly. However, I doubt this is going to be a significant cost on any system. Startup costs, although sometimes annoying, are seldom significant in terms of application performance.
Security. The is a certain level of security with a jar file. You have one jar file and distribute it to the help desk people. And one of them deletes it accidently. It is going to be a lot easier to figure that out than if they deleted one class file. Additionally it is probably easier to encrypt/decrypt a jar file (if you really must) than class files.
Dynamic class loading. If you are storing classes in non-traditional places, like a database rather than files, then it is probably going to be easier if you do it as class files.
Testing. It is easier to replace a class file in a testing environment to fix a bug than a jar file. Particularily if the make process for the jar file rebuilds everything. -
How to find a jar file a class is in
Given a class file, I would like to find out in which jar file it exists.
Please see my post "searching for a class in many jars" at
searching for a class in many jars
The basic idea is to find all the possible jars and then extract the entries in them and then filter out the desired string. You can filter for "JboException" or, "oracle/jbo/JboException". Note the forward slash here.
You can also write your own utility to do that. Or download some by googling.
By the way, that class is in my <ORACLE_HOME>\BC4J\lib\bc4jmt.jar. -
Loadjava resolves jar file but classes are not showing up in user_objects
Hello, oracle noob here,
I'm loading a vendor's jar file in oracle with loadjava with the -v -f -r flags and the classes I need and I see them either getting resolved or skipped:
c:\loadjava -r -f -v -genmissing -u "uid/pwd@mydbatrain" ekahau-engine-sdk.jar
resolving: class com/ekahau/common/sdk/EConnection
skipping : class com/ekahau/common/sdk/EErrorCodes
skipping : class com/ekahau/common/sdk/EException
skipping : class com/ekahau/common/sdk/EMsg
Classes Loaded: 114
Resources Loaded: 1
Sources Loaded: 0
Published Interfaces: 0
Classes generated: 0
Classes skipped: 0
Synonyms Created: 0
Errors: 0 Thinking everything went well I ran my routine to call EConnection but I get a NoClassDefFoundError on that call, which tells me that the aurora JVM can't find the class.
After chasing my tail with the server's CLASSPATH, it dawns on me that it should already be in the user_objects table since loadjava should have put it in there.
But when I query user_objects to see if EConnection is in there,
SQL> column object_name format a30
SQL> column object_type format a20
SQL> select object_name,object_type, status from user_objects where object_name like '%ekahau%';
OBJECT_NAME OBJECT_TYPE STATUS
com/ekahau/common/sdk/EMsg JAVA CLASS VALID
com/ekahau/common/sdk/IMsg JAVA CLASS VALID
com/ekahau/engine/sdk/Asset JAVA CLASS VALID
com/ekahau/engine/sdk/Device JAVA CLASS VALID
com/ekahau/engine/sdk/Event JAVA CLASS VALID
com/ekahau/engine/sdk/Location JAVA CLASS VALID
com/ekahau/engine/sdk/Model JAVA CLASS VALID
com/ekahau/engine/sdk/ModelMap JAVA CLASS VALID
com/ekahau/engine/sdk/TagMenu JAVA CLASS VALID
9 rows selected.
SQL> It's not there along with 104 other class I thought it loaded
I picked up the idea of running java inside oracle from an OCP and I can run a simple isolated java program myself and even make database calls.
But it seems I didn't get all the knowledge i need when it comes to loadjava and getting a jar files classes into user_objects to be useful.
Can anyone help an oracle noob with loadjava?Thank you, Gary.
I updated the post with the version info. I did not explicitly install this JDBC driver, so whatever the OSD came with? Unless it is using whatever is installed on my machine, in which case would be the thin driver.
I did check out that post, and I appreciate you sharing it. I did click the 'include synonyms' filter, but behavior remained unchanged.
I would prefer to use OSD, and that is what our dev team was expecting to use, but we just can't see the information. We are using an ID that does not 'own' those tables, per se. But, why would DBVisualizer show these tables, when OSD does not? -
I have a small swing application which connects to an external database and queries something and creates a small report on the local machine. Running from the command line calling the == java MyClass works good. I would like to deploy this to two other machines. I dont want the use to run from the command line solution. I want to run it from a batch file using the jar file. But I am getting a a classpath issue ( ClassNotFoundException for the jdbc drivers ) . I signed my jar file using jarsigner too. I am not interesed in using the Web Start because there are no other security attached to this app. Only couple of people intends to use it. Running from the command line calling the app file explicitly works. In the batch file I added the setclass path too. Still it gives an exception. I added the jdbc driver jar file to the appication jar file too. Still the problem exists.
Any ideas ?instead of including the JDBC driver inside your application's jar, have the two jars sit in a directory separatly and include both of them on your classpath. Or, you can even specify a manifest.mf Class-Path parameter for your application's jar file so that it automatically includes the driver's jar.
-
Which jar file include class - weblogic.utils.UnsyncStringBuffer?
When I compile my JSP file by using JDeveloper, but I got "Error: java.lang.NoClassDefFoundError: weblogic/utils/UnsyncStringBuffer". I don't know which jar file is including this class file, and where I can get that jar file?
This is my JSP file header
<%@page language="java" contentType="text/html;charset=UTF-8"%>
<%@taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
<%@taglib uri="netui-tags-html.tld" prefix="netui"%>
<%@taglib uri="netui-tags-template.tld" prefix="netui-template"%>
<%@taglib uri="cnt.tld" prefix="cnt" %>
<%@taglib uri="cnt-util.tld" prefix="cnt-util" %>
<%@taglib uri="c.tld" prefix="c"%>
Thanks,
lucyI doubt that a user who hasn't posted in 3+ years is going to wake up and answer you.
Probably best for you to post your details in a new thread (linking to here if you think it adds value)
You can always use Tools->Manage Libraries in JDeveloper and type the class name into the search box; it will tell you which libraries have the class. -
Problem: Multiple jar files in Class-Path [ IOException: line too long]
Hello Folks,
I am trying to create a jar file using the following command:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
My MANIFEST.MF file is as following:
Manifest-Version: 1.0
Main-Class: com.gridftp.INSPgridFTP
Class-Path: lib/activation.jar lib/ant.jar lib/antlr.jar lib/axis.jar lib/castor-0.9.3.jar lib/cog-abstraction-common-2.0.jar lib/cog-abstraction-examples-2.1.jar lib/cog-certmanagement-1.0.jar lib/cog-certrequest-1.0.jar lib/cog-grapheditor-0.46.jar lib/cog-gridfaces-1.0.jar lib/cog-gridshell-1.0.jar lib/cog-jglobus-1.2-050621.jar lib/cog-karajan-0.31.jar lib/cog-provider-clref-gt3_0_2.jar lib/cog-provider-clref-gt3_2_0.jar lib/cog-provider-clref-gt3_2_1.jar lib/cog-provider-clref-gt4_0_0.jar lib/cog-provider-condor-2.0.jar lib/cog-provider-gt2-2.0.jar lib/cog-provider-gt2ft-1.0.jar lib/cog-provider-gt3_0_2-2.0.jar lib/cog-provider-gt3_2_0-2.0.jar lib/cog-provider-gt3_2_1-2.0.jar lib/cog-provider-gt4_0_0-2.2.jar lib/cog-provider-local-2.0.jar lib/cog-provider-ssh-2.0.jar lib/cog-provider-webdav-1.0.jar lib/cog-resources-1.0.jar lib/cog-setup-0.91.jar lib/cog-util-0.91.jar lib/commons-discovery.jar lib/commons-httpclient.jar lib/commons-logging.jar lib/concurrent.jar lib/cryptix32.jar lib/cryptix-asn1.jar lib/cryptix.jar lib/j2ssh-common-0.2.2.jar lib/j2ssh-core-0.2.2.jar lib/jaas.jar lib/jakarta-regexp-1.2.jar lib/jakarta-slide-webdavlib-2.0.jar lib/jaxrpc.jar lib/jce-jdk13-125.jar lib/jgss.jar lib/jug-1.0.1.jar lib/junit.jar lib/log4j-1.2.8.jar lib/mail.jar lib/puretls.jar lib/saaj.jar lib/wsdl4j.jar lib/xercesImpl.jar lib/xml4j.jar lib/xml-apis-1.1.jar lib/xmlsec.jar lib/xpp3-1.1.3.4d_b4_min.jar lib/xstream-1.1.1-patched.jar .
The grid-jar directory structure is:
| - com -- all classes are under this dir.
| - lib -- all the required jar files are in this dir.
There are 59 jar files in the lib directory. When I try to create the jar file, I get the following exception:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
java.io.IOException: line too long
at java.util.jar.Attributes.read(Attributes.java:356)
at java.util.jar.Manifest.read(Manifest.java:167)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:124)
at sun.tools.jar.Main.main(Main.java:904)
Any idea, why do I get this exception? Is there any restriction as to how many jar files (or characters) can be there in the Class-Path value in the MANIFEST.MF file?
Please help.
Thanks,
Anause as the following way to resolve the problem:
(1) use separate lines, to avoid too long a line for java package name lists
(2) type a preceding space before each folloing lines, for example:
Class-Path: ...jar ...jar ...jar
...jar ..jar
...jar ...jar
...jar ...jar
Hello Folks,
I am trying to create a jar file using the following
command:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
My MANIFEST.MF file is as following:
Manifest-Version: 1.0
Main-Class: com.gridftp.INSPgridFTP
Class-Path: lib/activation.jar lib/ant.jar
lib/antlr.jar lib/axis.jar lib/castor-0.9.3.jar
lib/cog-abstraction-common-2.0.jar
lib/cog-abstraction-examples-2.1.jar
lib/cog-certmanagement-1.0.jar
lib/cog-certrequest-1.0.jar
lib/cog-grapheditor-0.46.jar
lib/cog-gridfaces-1.0.jar lib/cog-gridshell-1.0.jar
lib/cog-jglobus-1.2-050621.jar
lib/cog-karajan-0.31.jar
lib/cog-provider-clref-gt3_0_2.jar
lib/cog-provider-clref-gt3_2_0.jar
lib/cog-provider-clref-gt3_2_1.jar
lib/cog-provider-clref-gt4_0_0.jar
lib/cog-provider-condor-2.0.jar
lib/cog-provider-gt2-2.0.jar
lib/cog-provider-gt2ft-1.0.jar
lib/cog-provider-gt3_0_2-2.0.jar
lib/cog-provider-gt3_2_0-2.0.jar
lib/cog-provider-gt3_2_1-2.0.jar
lib/cog-provider-gt4_0_0-2.2.jar
lib/cog-provider-local-2.0.jar
lib/cog-provider-ssh-2.0.jar
lib/cog-provider-webdav-1.0.jar
lib/cog-resources-1.0.jar lib/cog-setup-0.91.jar
lib/cog-util-0.91.jar lib/commons-discovery.jar
lib/commons-httpclient.jar lib/commons-logging.jar
lib/concurrent.jar lib/cryptix32.jar
lib/cryptix-asn1.jar lib/cryptix.jar
lib/j2ssh-common-0.2.2.jar lib/j2ssh-core-0.2.2.jar
lib/jaas.jar lib/jakarta-regexp-1.2.jar
lib/jakarta-slide-webdavlib-2.0.jar lib/jaxrpc.jar
lib/jce-jdk13-125.jar lib/jgss.jar lib/jug-1.0.1.jar
lib/junit.jar lib/log4j-1.2.8.jar lib/mail.jar
lib/puretls.jar lib/saaj.jar lib/wsdl4j.jar
lib/xercesImpl.jar lib/xml4j.jar lib/xml-apis-1.1.jar
lib/xmlsec.jar lib/xpp3-1.1.3.4d_b4_min.jar
lib/xstream-1.1.1-patched.jar .
The grid-jar directory structure is:
| - com -- all classes are under this dir.
| - lib -- all the required jar files are in
e in this dir.
There are 59 jar files in the lib directory. When I
try to create the jar file, I get the following
exception:
jar -cvfm mygrid.jar MANIFEST.MF -C grid-jar/ .
java.io.IOException: line too long
at
at
at
at
java.util.jar.Attributes.read(Attributes.java:356)
at
at
at java.util.jar.Manifest.read(Manifest.java:167)
at
at
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:124)
at sun.tools.jar.Main.main(Main.java:904)
Any idea, why do I get this exception? Is there any
restriction as to how many jar files (or characters)
can be there in the Class-Path value in the
MANIFEST.MF file?
Please help.
Thanks,
Anajust -
Packaging jar file with classes
Hi experts,
I want to clarify a problem in relation with packaging .class files in jar file making
it jar executable.I was able to achieve this when number of classes are limited and confined to only a single program.However recently i developed a software
which is very much like SQL*Plus and retriee my company database using screen buffer management and i have handled almost all the issues.
But so long to execute this program i am typing
java <Program name>.It is using Oracle as backend.
I tried to package Oracle driver files in jar using
jar -cmf manifest.mf sqlpad.jar *.class Oracle\
where Oracle directory contains all the class files in separate folders like
Oracle\javax etc
I get a jar file with hefty MBs size.It is executable too.But when i try to connect to
database, i get message Oracle driver class is not found.
In what way should i package it as jar file ?I wouldn't add the drivers to the JAR itself. Instead, I'd suggest one of the following:
1.) Add classpath entries into your manifest file pointing to the drivers' JARs
2.) Create a batch file for starting that contains a call to "java -classpath ..."
3.) Add some way to your app to configure additional classpaths at runtime and use a URLClasssLoader (and a wrapper class for the driver for registering with the DriverManager) that loads the driver's class -
Encryption/decryption through jar file and classes
Hi,
My application uses tomcat as web server.
I am doing encrytion and decyption.
i fetch encypted data from database and then decrypt it
If i use calsses in webapps -> WEB-INF -> classes folder, i place classes in that ,
In other case i use jar file and place that file in WEB-INF -> lib folder in the webapps directory.
There is huge performance difference.
While using classes performance is great while using jar file performance is very disappointed.
I am using a file for encryption /decryption also.Are you getting any error messages? Have you put debugging code in those classes to see what is happening?
-
Loadjava - jar files INVALID Classes
Hi Gurus,
I loaded a couple of jar files to the database using loadjava and most of the classes are in invalid status because of inter dependencies. Is there a better way to do it?
command used: loadjava -u apps/apps -v -force <jar>
Also tried loading them using jdeveloper and it loaded them as JAVA RESOURCE, but I was not able to refer to the classes in the RESOURCE in my class. Does anyone have any experience with this?
Thanks,
VenkyHi Venky,
most of the classes are in invalid status because of inter dependencies. Here is a similar issue, and their solution:
http://dba.ipbhost.com/index.php?showtopic=6595
http://fredericktang.wordpress.com/2007/09/28/long-road-to-loadjava/
Hope this answers your question . . .
Donald K. Burleson
Oracle Press author
Author of "Oracle Tuning: The Definitive Reference":
http://www.dba-oracle.com/bp/s_oracle_tuning_book.htm -
Unable to access classes in third party jar files packaged with my ejb.jar
I have packaged some third party jar files in my xxx_ejb.jar file. The third party jar file contains classes that are accessed by some custom classes which are in turn accessed by my bean classes. I get the following error when my custom classes attempt to use any of the classes in one of the third party jar files:
java.lang.NoClassDefFoundError: com/Ostermiller/util/CSVParser
Shouldn't I be able to access classes in jar files that are packaged with my xxx_ejb.jar file? I see the xxx_ejb.jar file as a resource of the application classloader that contains it but I don't see the third party jar files.As per the Java EE specification, additional JAR files should be packaged on the EAR level. Only WAR files' WEB-INF/lib folder is scanned for JAR files to be added to the classloader.
-
Adding Classes to the JAR File's Classpath
Ques 1- Can I use the wildcard * symbol in Manifest file to add classes/othes jar files to the JAR File's Classpath.I have folder named - Lib . where there are many jar files.Now,do I have to add each jar file by- Class-Path: Lib/jar1-name Lib/jar2-name . Instead, can I do this- Class-Path: Lib/*.jar OR Class-Path: Lib/*.class
RIDICULOUS....105 views has been made but YET NO ANSWER. Isn't there anybody who knows the answer.
Edited by: Tanvir007 on Apr 30, 2008 2:21 AMQues 1- Can I use the wildcard * symbol in Manifest file to add ... other jar files ...?No. You could, however, place all your needed JARs in JavaHome/jre1.x.x/lib/ext - if this is a way for you.
Ques 2 ??
RIDICULOUS....105 views has been made but YET NO ANSWER.What hindered you to test it yourself?
And the things we don't know far exceed the things we know. Why do you wonder?
Have a nice day
J�rg -
How to search for a class to know it is in which Jar file
Hi Guys,
Can any tell me how to search a class file. I have a set of Jar files in which the required class file is there. But i don't know in which Jar file the class is. Is there any way to find out.
Regards,
Gowtham K.Hi Gowtham,
Please download the Class locator from the following site. This will help to know what you are looking for.
<b>http://www.alphaworks.ibm.com/tech/jarclassfinder</b>
<b>http://sourceforge.net/projects/classlocator</b>
I hope this solves your problem.
Regards
Pravesh
PS: Please consider rewarding points for helpful answer. -
Can I increase heap memory without specify any class or jar file??
Hi,
I tried to increase my heap memory in this way :
java -Xms256m -Xmx256m
but I got an error ... it's seem that I must specify a class java or a .jar file ...
This is the error :
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
can I increase heap memory without specify any class or jar file??
thxchiara wrote:
Hi,
I tried to increase my heap memory in this way :
java -Xms256m -Xmx256m
but I got an error ... it's seem that I must specify a class java or a .jar file ...
This is the error :
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
can I increase heap memory without specify any class or jar file??The job of java.exe is to execute java bytecode.
What is it supposed to do with your request to use 256m of memory for heap
when you are not giving it a class or a jar to run?
Maybe you are looking for
-
How to overload two different procedure with just one name in to package
i have created two procedure avg1 and avg2.avg1 calculate average of total salary based on e_id and avg2 calculate average based on j_id.now i want to create a package with specification and body where i want to use just one name -avg- for two differ
-
How to rename the existing project in NetWeaver
Hi All, Please let me know the process of how to rename the existing project in NetWeaver.
-
Hi, does anyone know if the Jabra bt 3030 will work with iOS 5?
Hi I was wondering if the Jabra BT3030 handsfree stereo headseat will work with the new ios 5.
-
I would like to be able to write in iBooks. I thought I read some place that this was possible. Is this true, or do I need an app?
-
Tune to other Channel that's already recording while it's recording
Maybe this is just the result of a horrible UI, but if I'm recording two shows, I'm on one of the channels (obviously), and want to switch to the other one LIVE (not go to the DVR and "play" what's recorded so far from the beginning), is this possibl