How do class paths work with JAR files?
Hey all,
I have in the manifest file a path to a folder, plugins. In it I have a dir and files myDir/*.* so when unzipped it has <install-dir>/plugins/myDir/*.*. In the MF file I indicate the plugins dir as part of the class-path. When I want to load a .class file from the myDir/ dir below plugins, and the classes in there do NOT have package names in them, how is that done? Every time I try to access a file via Class.forName() it says ClassNotFoundException. If I hard-code the string as "myDir/myplugin" or use package identifer "myDir.myplugin" it still doesn't work. I don't want to unzip a ton of files from each plugin in one dir. I want a more organized way of storing them. However, because plugins can be added after the file is unzipped, I can't specify all the locations of plugins/<dir> dir's in the MF file if more are added later. Is there a way to locate and load a class in ANY dir, even those that are NOT in the class-path? Please help me out if you know. Thanks.
I really can't help accept to say that it is the way it is to avoid naming conflicts i think. can you make the plugins packages ? Otherwise especially if various people write them there may be some crazy naming conflicts hidden in trying to load things from anyplace.
Similar Messages
-
Hi Friends
I created a project and tried to Make a Executable jar file. actually. got it. it is also Running when i click on the Executable jar file.
Now my problem is I am using some Images for my application those images are in a directory Called Image . when i make JAR File.
i use This Command
jar cfvm Setup.jar Manifest.txt *.class Imageit creates a JAR Files called setup.
it runs the Application also when i run the Project. Now when i copy the Setup.jar to some other Location Other than the Current Location.
It is not showing the Images which are allready in my Application
I don't the problem. I read through the java tutorials But i am not able to find out the Solution for this Problem
Please help me out to overcome this Problem
Thank you for your service
Cheers
JofinHi thank you for your reply
Realy i don't follow what you say, Where you are telling me to add this line Main.class.getResource("Image/file.gif"). Whether in The Manifest File or Where ever, i read the Images?
Actually i have 5 JFrame Where all the Frames Uses Images. Should i need to use this Line in all the 5 classes . Could you please explain me clearly.
i am very new to java. so that i am not able to pick up quickly. please bare with me
Thank you for your service
Cheers
Jofin -
How do Classpaths work with JAR files?
Hey all,
I have in the manifest file a path to a folder, plugins. In it I have a dir and files myDir/*.* so when unzipped it has <install-dir>/plugins/myDir/*.*. In the MF file I indicate the plugins dir as part of the class-path. When I want to load a .class file from the myDir/ dir below plugins, and the classes in there do NOT have package names in them, how is that done? Every time I try to access a file via Class.forName() it says ClassNotFoundException. If I hard-code the string as "myDir/myplugin" or use package identifer "myDir.myplugin" it still doesn't work. I don't want to unzip a ton of files from each plugin in one dir. I want a more organized way of storing them. However, because plugins can be added after the file is unzipped, I can't specify all the locations of plugins/<dir> dir's in the MF file if more are added later. Is there a way to locate and load a class in ANY dir, even those that are NOT in the class-path? Please help me out if you know. Thanks.You have two options:
1) Add a Class-Path entry for each plug-in directory, not just the plugins.
Class-Path: plugins/myDir plugins/yourDir2) Go ahead and put the plug-ins in separate packages - package handling makes doing plug-ins easier in the long run. Two ways:
package plugins.myDir; // no Class-Path entry requiredor
package myDir; // which works with your current Class-Path -
Multiple Class-Path: attributes in Jar files
Hello,
I'm packaging a set of jar files for distribution with Class-Path: attributes in them. In the documentation I read and in one of the java trails it said that I could have a manifest file like:
Class-Path: log4j.jar log4j-core.jar
Class-Path: jsse.jar jcert.jar jnet.jar
But this doesn't work. It only works when I do this:
Class-Path: log4j.jar log4j-core.jar jsse.jar jcert.jar jnet.jar
Here is how I'm running the jar:
java -jar server.jar
Is the documentation wrong? Or this is a bug?
thanks
charlieCertain attributes were only meant to be specified once. Like Main-Class and Class-Path for example. If these were listed two or more times, then the last occurance is the one that gets recognized (basically, each new instance overwrites the previous instance). Some attributes are listed as "per-entry" and are freely duplicated for each entry. For example signed jars could have a number of Name: and xxx-Digest: attributes.
This link is to the manifest spec:
http://java.sun.com/products/jdk/1.2/docs/guide/jar/manifest.html
To answer the original posters question, the doc's are in error. Actually, the error was not in the docs, it was in the tutorial, but none the less its still in error. He could have done this:
Class-Path: log4j.jar log4j-core.jar
jsse.jar jcert.jar jnet.jar
^-- two spaces before the start of jsse.jar
because the docs allow for line continuation (although it's not exactly clear if you read the docs). The docs are also apparently in error regarding the max line length of 72 bytes. I have tested this with over 100 char's on a win32 machine and it works fine for me. The limitation must therefore apply to some other operating system, or it could just be in error.
-Ron -
Anybody know how to use jave work with mapping file? help!
mapping file are somehow those...
<db-insert root-element>
.....<map-info>
something like that, and I dont know how java code can use with them..my database is mysql...
or any reference site is good.?
Thank you very muchurm...thanks..
my job is about to write a transformation tool to transform XML documents into a database. The tools is written for users to extract data in XML format and store it into a database. But i would choose MYSQL. Mapping files are used to store information correctly into database to avoid the need to write new code for each type of XML files. And can choose any programing langugage for implementation such as Java and C#.........and currently still looking on Java or VB -
How to dynamically find the dependent jar files on user's PC
I've written an application to deal with JTAPI. Unfortunately the implementations by vendors are different in terms of file names. Ideally I'd like to load jars based upon what's installed, e.g. load jtapi.jar when Cisco is installed, or Escjtapia.jar when it's Avaya. The application uses a small subset of JTAPI so different implementations should not yield any different results.
I edited the manifest file in my jar so that the Class-path has both jar file names for Cisco and Avaya. I didn't enter any path, hoping the CLASSPATH of Windows would be searched, but it is not the case. Also, if other vendors are supported in the future, I might have to add all different file names in the manifest. I don't think the class loader will work in my case, as I may not know the class name at all. I just want to search the system's classpath the find any jar complys to JTAPI and load it.
Anybody can give suggestions on deployment? Thanks!I found it. EXIT_SAPLV01Z_001 does the trick. A package contains many User-Exits, BADIs and enhancement points, so it took me a while to go thru all of them.
-
I would appreciate any suggestion as to how best one can work with big files. I have eight one hour tapes containing information about various places I visited. Some contain only one place while others can contain two or more places. As a preference I like to create up to one hour DVDs that contain an identifiable segment; eg either one place only or more but I do try not to break up a place and record it on two DVDs. However, the problem I faced in the past, is that by the time I get to the end of an hour, the program Premiere Elements 7 (PE7) is getting slow and keeps telling me that it is running out of memory. That is despite the fact that I have 3 GM of RAM and over 200 GB of dedicated separate hard drive. I tried saving segments under ‘Share’, ‘DV AVI’ and selecting ‘DV PAL Standard’ (the system I use), but the result, as far as quality was concerned, was very disappointing. There is no option to change or set quality as was the case in previous versions of PE. Nor can I combine two .prel files into one while I am editing.
Is there any other way I can work in segments, say 15 minutes, and combine them at the end without losing on the quality?
Any suggestion would be most appreciated.
TomHi Steve
It is a Sony DCR-HC40E PAL, and they were captured as AVI clips.
The project settings are:
General – not highlighted but it shows DV Pal and 25.00 frame/second
Video – 720 horizontal 576vertical (4/3)
Display format - 25 fps Timecode
Capture – DV Capture
Tom -
How to create and use library JAR files with command-line tools?
Development Tools -> General Questions:
I am trying to figure out how to put utility classes into JAR files and then compile and run applications against those JAR files using the command-line javac, jar, and java tools. I am using jdk1.7.0_17 on Debian GNU/Linux 6.0.7.
I have posted a simple example with one utility class, one console application class, and a Makefile:
http://holgerdanske.com/users/dpchrist/java/examples/jar-20130520-2134.tar.gz
Here is a console session:
2013-05-20 21:39:01 dpchrist@desktop ~/sandbox/java/jar
$ cat src/com/example/util/Hello.java
package com.example.util;
public class Hello {
public static void hello(String arg) {
System.out.println("hello, " + arg);
2013-05-20 21:39:12 dpchrist@desktop ~/sandbox/java/jar
$ cat src/com/example/hello/HelloConsole.java
package com.example.hello;
import static com.example.util.Hello.hello;
public class HelloConsole {
public static void main(String [] args) {
hello("world!");
2013-05-20 21:39:21 dpchrist@desktop ~/sandbox/java/jar
$ make
rm -f hello
find . -name '*.class' -delete
javac src/com/example/util/Hello.java
javac -cp src src/com/example/hello/HelloConsole.java
echo "java -cp src com.example.hello.HelloConsole" > hello
chmod +x hello
2013-05-20 21:39:28 dpchrist@desktop ~/sandbox/java/jar
$ ./hello
hello, world!I believe I am looking for:
1. Command-line invocation of "jar" to put the utility class bytecode file (Hello.class) into a JAR?
2. Command-line invocation of "javac" to compile the application (HelloConsole.java) against the JAR file?
3. Command-line invocation of "java" to run the application (HelloConsole.class) against the JAR file?
I already know how t compile the utility class file.
Any suggestions?
TIA,
DavidI finally figured it out:
1. All name spaces must match -- identifiers, packages, file system, JAR contents, etc..
2. Tools must be invoked from specific working directories with specific option arguments, all according to the project name space.
My key discovery was that if the code says
import com.example.util.Hello;then the JAR must contain
com/example/util/Hello.classand I must invoke the compiler and interpreter with an -classpath argument that is the full path to the JAR file
-classpath ext/com/example/util.jarThe code is here:
http://holgerdanske.com/users/dpchrist/java/examples/jar-20130525-1301.tar.gz
Here is a console session that demonstrates building and running the code two ways:
1. Compiling the utility class into bytecode, compiling the application class against the utility bytecode, and running the application bytecode against the utility bytecode.
2. Putting the (previously compiled) utility bytecode into a JAR and running the application bytecode against the JAR. (Note that recompiling the application against the JAR was unnecessary.)
(If you don't know Make, understand that the working directory is reset to the initial working directory prior to each and every command issued by Make):
2013-05-25 14:02:47 dpchrist@desktop ~/sandbox/java/jar
$ cat apps/com/example/hello/Console.java
package com.example.hello;
import com.example.util.Hello;
public class Console {
public static void main(String [] args) {
Hello.hello("world!");
2013-05-25 14:02:55 dpchrist@desktop ~/sandbox/java/jar
$ cat libs/com/example/util/Hello.java
package com.example.util;
public class Hello {
public static void hello(String arg) {
System.out.println("hello, " + arg);
2013-05-25 14:03:03 dpchrist@desktop ~/sandbox/java/jar
$ make
rm -rf bin ext obj
mkdir obj
cd libs; javac -d ../obj com/example/util/Hello.java
mkdir bin
cd apps; javac -d ../bin -cp ../obj com/example/hello/Console.java
cd bin; java -cp .:../obj com.example.hello.Console
hello, world!
mkdir -p ext/com/example
cd obj; jar cvf ../ext/com/example/util.jar com/example/util/Hello.class
added manifest
adding: com/example/util/Hello.class(in = 566) (out= 357)(deflated 36%)
cd bin; java -cp .:../ext/com/example/util.jar com.example.hello.Console
hello, world!
2013-05-25 14:03:11 dpchrist@desktop ~/sandbox/java/jar
$ tree -I CVS .
|-- Makefile
|-- apps
| `-- com
| `-- example
| `-- hello
| `-- Console.java
|-- bin
| `-- com
| `-- example
| `-- hello
| `-- Console.class
|-- ext
| `-- com
| `-- example
| `-- util.jar
|-- libs
| `-- com
| `-- example
| `-- util
| `-- Hello.java
`-- obj
`-- com
`-- example
`-- util
`-- Hello.class
19 directories, 6 filesHTH,
David -
How to handle 2 or more .jar files with an applet
Hey out there
I have created an ftpClient application that uses "jakarta ftpClient". It works fine as an JFrame application � But when I converted the Application into an JApplet I get the following Exception:
java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
I have bundled the main application into a .jar file (Application,jar). But I don't know how to handle the 2 jakarta .jar files with my JApplet??
I Tried to append the 2 jakarta .jar files to the Application,jar with the following code:
jar cvf Application.jar 1.class 2.class�. commons-net-1.4.1.jar jakarta-oro-2.0.8.jar
But with the same result / Exception (I have signed the Jar file!)
Can anyone help meHi i have a question with your application can you down- or upload more files at the same time? Because i'm having problems with my ftp application.
Here is the link with my problem maybe you can help me. I will be very pleased when you can help me.
http://forum.java.sun.com/thread.jspa?threadID=5162042&tstart=0
Thx
Satanduvel -
How to use javap with jar files ?
how to use javap with jar files ?
thanksAs long as the jar is on the class path, your gold. So,
javap -classpath myjar.jar mypackage.MyClass
Chuck -
How can I get a single jar file with NetBeans?
How can I get a single jar file with NetBeans?
When I create the project I get these files:
dist/lib/libreria1.jar
dist/lib/libreria2.jar
dist/software.jar
The libraries that have been imported to create the project are in separate folders:
libreria1/libreria1.jar
libreria2/libreria2.jar
libreria1, libreria2, dist folders are all located inside the project folder.
I added the following code to the build.xml:
<target name="-post-jar">
<jar jarfile="dist/software.jar">
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
<zipfileset src="dist/lib/libreria1.jar" excludes="META-INF/*" />
<zipfileset src="dist/lib/libreria2.jar" excludes="META-INF/*" />
<manifest>
<attribute name="Main-Class" value="pacco.classeprincipale"/>
</manifest>
</jar>
</target>
Of course there is also the project folder:
src/pacco/classeprincipale.form
src/pacco/classeprincipale.java
Can you tell me what is wrong? The error message I get is as follows:
C:...\build.xml:75: Problem creating jar: archive is not a ZIP archive BUILD FAILED (total time: 2 seconds)This is not a NetBeans forum, it is a JDeveloper forum. You might want to try http://forums.netbeans.org/. I also saw your other question - try looking in the New to Java forum: New To Java
-
How to determine the path of the jar file cache of javawebstart?
Hello, I need to know how to determine where the java web start application
file jar cache is stored on windows system hard drive.
I would have launch of the inner processes
I have need to know the path of file jar .
example if my application is myAppliation.jar
in code generic class of myAppliation.jar i have the command runtime
String strCmd =
System.getProperties().getProperty("java.home") + "\\bin\\java" +
" -cp " +
System.getProperties().getProperty("java.class.path") + ";"
+ " anotherClass.class ";
Runtime.getRuntime().exec(strCmd);
the anotherClass.class has need
of the contained library in myAppliation.jar.Thanks i have tried this metod and function
java.net.URL resource = classLoader.getResource("myResource");
if (resource != null) {
String s = resource.toString();
if (s.startsWith("jar:")) {
int index = s.indexOf("!");
if (index > 4) {
String fileurl = s.substring(4, index);
if (fileurl.startsWith("file:")) {
String path = fileurl.substring(5);
// now path is the path to the jar file in the cache containing the resource
System.out.println("file jar: "+path);
} -
How Can I Work With PHTML Files In Dreamweaver ??
I want to work with PHTML files in Dreamweaver CS3 - How do I
go about getting this to work?The solutions is either of the following:
Adobe Lightroom - Find moved or missing files and folders
Copy the photos back into the exact same folder and folder location that they were in before
I don't know what you actually did "when I pasted it back" ... but the bigger issue is that you shouldn't be working with these files in your operating system, period. Once you import them into Lightroom, you don't manage these files in your operating system. -
How can I include 3rd party jar files with my custom extention?
I'm writing an extension that is dependent upon some 3rd party jars. How can I include/package these with my extension?
we're using the 11g tech preview
thanks,
DylanDo you mean that you need these files to appear in JDeveloper as a library available for the developers who build a project and use your extension?
You can create a library in JDeveloper with JAR files by simply adding the following to your extension.xml file:
<jdeveloper-hook xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension">
- <libraries xmlns="http://xmlns.oracle.com/jdeveloper/1013/jdev-libraries">
<library name="My Extension Library">
<classpath> ${ide.extension.install.home}/lib/some.jar</classpath>
</library>
</jdeveloper-hook> -
HI,
My daughter will often ask me to give her raw files I've taken at family events so that she can process them in her own copy of LR. (I work too slowly, apparently.) Recently I inadvertently cut instead of copied a folder. When I pasted it back I could see it in Windows Explorer but not in my LR library. I thought that re-importing the files might work, LR gave me a message that they were already imported. I expect there is a way to make the files available again in LR and would be grateful for some advice.
thanks
KenThe solutions is either of the following:
Adobe Lightroom - Find moved or missing files and folders
Copy the photos back into the exact same folder and folder location that they were in before
I don't know what you actually did "when I pasted it back" ... but the bigger issue is that you shouldn't be working with these files in your operating system, period. Once you import them into Lightroom, you don't manage these files in your operating system.
Maybe you are looking for
-
How to populate the CST and VAT registration no in billing.
Hello Gurus , Goodevening , How to populate VAT NO and CST NO of Customer and Company in the invoice of the customer. Looking for your inputs Regards Ravi.M
-
Hello, I created a JFileChooser (meCreateChooser) which shows up when the user clicks on a JMenuItem. The user has to type a name for his file and the program checks to see if that name already exists. If the typed file name already exists, the progr
-
PROBLEM IN DOWNLOADING PHOTOSHOP
AM KELVIN AND I HAVE TRIED TO DOWNLOAD ADOBE PHOTOSHOP TRIAL BUT IT HAS FAILED KINDLY ASSIST
-
How to use the fixed exchange rate 1009 (global rollout subsidiaries)?
Hi Experts, I am doing currency conversion.My requirement is i need to take fixed exchange rate type of 1009. I am handling 16 different types of currencies that to be converted into US$. Can anyone help me out how to use the exchange rate(1009) and
-
Why did I have to pay for pages for iPhone 5 running iOS 7?
Why did I have to pay for pages for iPhone 5 running iOS 7?