Locating classes given many JAR files

This may seem a basic thing, but I'm having trouble figuring out how people locate the correct JAR file to include when given just the package and class name.
In searching for a solution to a problem I'd come across web document that tell me all about a particular class or set of classes that will solve this or that problem. The document goes on to give me the package name that the class(es) belong to. The problem is, these classes are in a JAR file and the document doesn't tell me the name of the JAR file or where to get it - assuming I don't have it.
Assuming I do have the JAR file, that JAR file is usually in a directory with many more JAR files (for example, WSAD includes a whole bunch of JAR files or me). What's the best way to locate the package and/or class file(s) within all these JAR files? Why don't authors tell us the name of the JAR file these class(es) are in? Does anyone else have this problem besides me?

Haven't tried. But still worth having a look into this free plug-in for Eclipse.
http://www.icewalkers.com/Linux/Software/520170/JAR-Class-Finder.html
Thanks
Venkat

Similar Messages

  • 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 AM

    Ques 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

  • Is it possible to call a class in a jar file from JNI environment?

    Hi
    Is it possible to call a class in a jar file from JNI environment?
    Thanks in advance.

    Could you explain a bit more what you are trying to do? (In other words, your question is vague.)
    o If your main program is written in C, you can use JNI to start a JVM, load classes from the jar of your choice, and call constructors and methods of the objects defined in the jar.
    o If your main program is java, and has been laoded from a jar, a JNI routine can call back into java to use the constructors and methods of classes defined in the jar(s).

  • How  to include the inner classes in a jar file in netbeans ide

    Dear java friends
    how to say to netbeans ide that it has to include the
    inner classes in the jar file.
    (i have one single applet class
    with two inner classes that show up
    in the build/classes file but not in the jar).
    The applet works in the viewer but not
    in the browser (I believe because the
    xxx$yyy etc should be in the jar)
    willemjav

    First, please stop posting the same question multiple times:
    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=5269782&messageID=10127496#10127496
    with an answer.
    Second, If your problem is that you can't do this in NetBeans, you need to post to somewhere that provides NetBeans support - like the NetBeans website's mailing list. These forums do not support NetBeans (or any other IDE) - they are Java language forums.

  • Can I create a JTA EntityManagerFactory in a utility class in a .jar file?

    I have utility classes in a .jar file inside of a .war file deployed in Glassfish 3.1. One of these utility classes, CredentialsUtil, needs to access a database. I can't inject an EntityManager into CredentialsUtil since it is not an EJB. (For security reasons I don't want to make CredentialsUtil an EJB. I want it to be a POJO.)
    In CredentialsUtil I need an EntityManagerFactory that is connected to a datasource defined in Glassfish. Here is the line from CredentialsUtil.java and from the persistence.xml both of which will be in the util.jar file:
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("Credpu");
    <persistence-unit name="Credpu" transaction-type="JTA">
    I can't use RESOURCE_LOCAL since any changes to the datasource configuration must be done in Glassfish rather than changing persistence.xml.
    (The transaction context is not important in CredentialsUtil. It will be called by a WS-Security handler which may not have a transaction context.)
    Can I put the persistence.xml and the CredentialsUtil class that creates the EntityManagerFactory from it inside of the util.jar file (which will be in a .war), or do I have to move the class and a copy of the persistence.xml file out to the .war file? (I'll have to leave persistence.xml in the .jar file too since there are some @Entity in the .jar file. I don't know why but there are @Entity pojos in the .jar file.)
    I'd like to use the existing persistence.xml, but if I can't is there is a way to create an EntityManagerFactory (or EntityManager) that gets its datasource directly from Glassfish, ignoring persistence.xml?
    Thanks.

    Styles in Pages are saved in the documents (or templates). There is no easy method for adding a style to a built-in template (and it is strongly recommended that you do not tamper with them). You can open a built- in template, add your style and save it as a user template so that your new style will be standard in documents created from that template.

  • Is it possible to load classes from a jar file

    Using ClassLoader is it possible to load the classes from a jar file?

    URL[] u = new URL[1] ;
    u[0] = new URL( "file://" + jarLocation + jarFileName + "/" );
    URLClassLoader jLoader = new URLClassLoader( u );
    Object clsName = jLoader.loadClass( clsList.elementAt(i).toString() ).newInstance();
    I get this error message.
    java.lang.ClassNotFoundException: ExceptionTestCase
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
    // "file://" + fileLocation + fileName + "/" This works fine from a browser.
    Is there anything I am missing? Thanks for the reply.

  • How to combine the classes from 2 jar files into 1?

    Hi there
    I have got 2 jar files with the same name but the classes that they contain are different. So, I want to combine those 2 files into 1. Could anyone please tell me how to add the classes in a jar file to another jar file?
    Thanks for your help!
    From
    Edmund

    The jar utility allows you to extract files as well as put them into a jar. This is in the java docs.
    You might have to hand modify the manifest file if it was hand modified in the first place. All you should have to do is copy the text from one file to another. The manifest will have the same name so you will have to extract to different dirs so it isn't overwritten.
    Steps:
    -Create dir1 and dir2
    -Extract jar1 into dir1, Extract jar2 into dir2.
    -Manually examine manifests and combine if needed.
    -Copy files from one dir to another.
    -Use jar tool to create new jar.

  • Accessing classes in external jar files

    I have a jar file called main. I want it to be able to acces the classes in another jar file say test.jar how do i do this.
    Thank you

    ok, if i have this right...
    you have 2 directories that hold 2 .jars, right?
    plugins/ -------- build/plugins .jar
    systemModuals/ ------- DiaryUI and Loader .jar
    Your main JAR is diary?
    Diary.jar
    you want Diary to run with the jars inside plugins and systemmoduals?
    you set the "class-path:" tag like this....
    write this manifest file. save it as Manifest.txt and put it in your home dir.
    Main-Class: YourMainClass
    Class-Path: Diary.jar plugins/this.jar systemmoduals/diaryui.jar
    <make sure to hit enter, go to the next line>
    command line to your parent directory.
    jar cmf Manifest.txt Diary.jar build/main/*.class
    you should be set to go.
    use
    jar xf META-INF/MANIFEST.MF
    to read the present manifest that netbeans has created
    if necessary

  • How do I list all classes in a Jar file?

    How do I list all classes in a Jar file?

    Its no problem if the jar file contains classes, but I have an EAR file, which contains a jar-file, and I want to list all classes in that jar-file.
    I would like to do something like this:
    java.util.jar.JarFile jarfile = new java.util.jar.JarFile( new File("/meYear.ear"), true );
    java.util.jar.JarEntry jar = jarfile.getJarEntry( "myJar.jar" );
    // Cast it to a new JarFile:
    java.util.jar.JarFile newJar = (java.util.jar.JarFile)jar;
    But the method getEntry returns something like jarFile$JarEntry, if I try to class cast it I get an classCastException.

  • How do I import classes in a jar file?

    I have the following directory structure, each directory is a seperate package of the same name as the directory
    RPGUniversal
    RPGMap
    RPGCharacter
    RPGCharacter is not done yet so I am ignoring that package for now.
    RPGCharacter and RPGMap both depends on classes inside the RPGUniversal Package, but are independant of eachother and RPGUniversal is completely independant.
    I want to place each package in it's own .jar file for use as a library in later programs.
    I placed all the compiled classes for RPGUniversal inside the proper directory structure, I then used this command to place it in a jar:
    jar -cf ./RPGUniversal.jar ./RPGUniversal/*
    I then tested the contents with this command:
    exodist@Abydos:/stuff/JProject/test$ jar -tf RPGUniversal.jar
    META-INF/
    META-INF/MANIFEST.MF
    RPGUniversal/ADTs/
    RPGUniversal/ADTs/t1.jpg
    RPGUniversal/ADTs/t2.jpg
    RPGUniversal/ADTs/t3.jpg
    RPGUniversal/ADTs/t4.jpg
    RPGUniversal/ADTs/Coordinates.class
    RPGUniversal/ADTs/RPGImage.class
    RPGUniversal/ADTs/FrameSet.class
    RPGUniversal/ADTs/ImageTester.class
    RPGUniversal/Exceptions/
    RPGUniversal/Interfaces/
    RPGUniversal/Interfaces/RPGCharacter.class
    RPGUniversal/Interfaces/RPGItem.class
    RPGUniversal/Interfaces/RPGObject.class
    RPGUniversal/Interfaces/Trackable.class
    RPGUniversal/Interfaces/Tracker.class
    RPGUniversal/Interfaces/RPGMapComponent.class
    RPGUniversal/Interfaces/RPGMap.class
    so far all good, next I delete the RPGUniversal directory leaving the only file in the current directory RPGUniversal.jar
    next I create the RPGMap directory and give it the proper .java files and directory tree.
    I then run a script to compile every .java file
    for i in `find ./ -name "*.java"`; do javac "$i"; done
    and I get a ton of dependancy errors:
    exodist@Abydos:/stuff/JProject/test$ for i in `find ./ -name "*.java"`; do javac "$i"; done
    ./RPGMap/BaseClasses/StaticMap.java:13: package RPGUniversal.Interfaces does not exist
    import RPGUniversal.Interfaces.*;
    ^
    ./RPGMap/BaseClasses/StaticMap.java:20: cannot resolve symbol
    symbol : class RPGMap
    location: class RPGMap.BaseClasses.StaticMap
    public abstract class StaticMap implements RPGMap
    ^
    ./RPGMap/ComponentClasses/MapTile.java:9: package RPGUniversal.Interfaces does not exist
    import RPGUniversal.Interfaces.*;
    ^
    ./RPGMap/ComponentClasses/MapTile.java:10: package RPGUniversal.ADTs does not exist
    import RPGUniversal.ADTs.*;
    ^
    ./RPGMap/ComponentClasses/MapTile.java:16: cannot resolve symbol
    symbol : class RPGObject
    location: class RPGMap.ComponentClasses.MapTile
    public class MapTile implements RPGObject
    ^
    ./RPGMap/ComponentClasses/MapTile.java:19: cannot resolve symbol
    symbol : class RPGImage
    location: class RPGMap.ComponentClasses.MapTile
    private RPGImage MyImage;
    ^
    ./RPGMap/ComponentClasses/MapTile.java:31: cannot resolve symbol
    symbol : class Coordinates
    location: class RPGMap.ComponentClasses.MapTile
    public boolean CheckForCollision(Coordinates C)
    ....the list goes on........
    how do I tell it to look inside the RPGUniversal.jar file to find the required classes?
    here is a directory tree so you can see how it is set up:
    ls -R1
    RPGMap/
    RPGUniversal.jar
    ./RPGMap:
    BaseClasses/
    ComponentClasses/
    ExternalInterfaces/
    HigherClasses/
    InternalInterfaces/
    ./RPGMap/BaseClasses:
    StaticMap.java
    ./RPGMap/ComponentClasses:
    MapTable.java
    MapTile.java
    TableList.java
    TileSet.java
    ./RPGMap/ExternalInterfaces:
    ./RPGMap/HigherClasses:
    DynamicMap.java
    ./RPGMap/InternalInterfaces:

    The JAR file needs to be in the compliers classpath : javac -classpath "$CLASSPATH:RPGUniversal.jar" "$i"

  • Dinamyc class loading and jar files

    I'm new to java. I would like to load some plugins in my application (it's going to be packaged as a jar at the end). I managed to find some dinamyc class loading examples but they search for the classes to load in a directory.
    This is the code:
        public static void main(String[] args) {
            File pluginDirectory = new File("src/pluginsreloaded/plugins");
            if (!pluginDirectory.exists()) {            // the plugin directory does not exist
                System.out.println("The plugins directory does not exist!");           
                return;
            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".class");
            String[] pluginFiles = pluginDirectory.list(filter);
            for (int i = 0; i < pluginFiles.length; i++) {
                if (pluginFiles.indexOf("$") == -1) {
    System.out.println("Loading: " + pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    IPlugin plugin = pm.loadPlugin(pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    System.out.println(plugin.description());
    protected static IPlugin loadPlugin(String name) {
            // Query the plugin list for the plugin
            PluginFactory _plugin = (PluginFactory) pluginList.get(name);
            if (_plugin == null) {          // the plugin is not loaded
                try {
                    Class.forName("pluginsReloaded.plugins." + name);
                    // The plugin makes an entry in the plugin list
                    // when loaded
                    _plugin = (PluginFactory) pluginList.get(name);
                    if (_plugin == null) {
                        return null;
                } catch (ClassNotFoundException e) {
                    System.out.println("Plugin " + name + " not found!");
            return _plugin.create();
        }IPlugin is an interface. I am using netbeans 5.0. The error I get is this:
    Exception in thread "main" java.lang.NoClassDefFoundError: pluginsReloaded/plugins/plugin1 (wrong name: pluginsreloaded/plugins/plugin1)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:164)
            at pluginsreloaded.PluginManager.loadPlugin(PluginManager.java:30)
            at pluginsreloaded.Main.main(Main.java:44)
    Java Result: 1As far as I can see it can't find the class. My question is how can I load the class/where can I find it?
    Thanks.

    You can use the java.util.jar.JarFile class to enumerate the contents of a jar. It's not good practice to search for plugins in this way though. A plugin may well involve serveral classes, which don't all have to be internal. Furthermore its wise to avoid any comitment about the mechaism by which class files are to be fetched. You might want to do it remotely, some time, or load them from a database.
    What seesms to be the standard approach is to put a list of plugin classes into the jar as a text file.
    Plugins for a given purpose usually implement some specified interface, or extend some abstract class to which their objects can be cast once loaded (without this they aren't really much use).
    Say your plugins implment org.myorg.WidgetFactory then you put a list of them, one fully qualified name to a line, in a file or jar entry called META-INF/services/org.myorg.WidgetFactory. You framework picks up all such files from the classpath using ClassLoader.getResources() and loads all the classes whose names if finds, hence you can add new sets of plugins just by adding a new jar or class directory to the class path.

  • Java class uses another class in a Jar file (How do I make Java see it)?

    I am trying to figure out how do I make Javac see the thinlet.class in the thinlet.jar.
    I have developed an XUL xml interface and a java program that calls the interface shown below:
    //package thinlet.demo;
    import thinlet.*;
    public class UI extends Thinlet
    { public UI () throws Exception {add(parse("UI.xml"));}
    public static void main(String[] args) throws Exception
    { new FrameLauncher("UI", new UI(), 600, 600); }}
    when I do the normal compile, I get an error:
    UI.java:4: cannot find symbol
    symbol: class Thinlet
    public class UI extends Thinlet {
    ^
    UI.java:7: cannot find symbol
    symbol : method parse(java.lang.String)
    location: class thinlet.demo.UI
    add(parse("UI.xml"));
    ^
    UI.java:12: cannot find symbol
    symbol : class FrameLauncher
    location: class thinlet.demo.UI
    new FrameLauncher("UI", new UI(), 600, 600);
    ^
    3 errors
    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.

    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.You just still haven't provided the jar in the classpath, or you're not using the right class name. Is the class really named thinlet.Thinlet? Or are you thinking "import thinlet.*" means to import all classes in a jar named thinlet.jar? Because the latter is not true. You need to import classes, not jar file names.

  • JDev10.1.2: Difference betwn same oracle.jbo.classes in different jar files

    Hello guys, does somebody knows the difference between these two JDeveloper 10.1.2 directories?
    JDEV_HOME/BC4J/lib
    JDEV_HOME/BC4J/jlib
    And more deeply, why are there different jar files both containing classes like oracle.jbo.domain.Number and oracle.jbo.domain.Date? I explain: you can find oracle.jbo.domain.Number in JDEV_HOME/BC4J/lib/bc4jdomorcl.jar and in JDEV_HOME/BC4J/jlib/bc4jdomgnrc.jar ?
    This is very strange.
    I ran into trouble because both oracle.jbo.domain.Number classes where being loaded, I was importing into my project the BC4J Generic Domains library which points to the BC4J/jlib/bc4jdomgnrc.jar, so I took it off of my project and added the BC4J/lib/bc4jdomorcl.jar as an additional path in the classpath because this is the one referenced by the embedded OC4J in the application.xml file.
    Thank you.

    Refer to the section BC4J Runtime Libraries
    If you are using the Oracle type mappings, use bc4jdomorcl.jar. If the application was built using "Java" type mapping, use bc4jdomgnrc.jar which is located in <jdev_install>/bc4j/jlib.
    http://213.35.38.54/otn_hosted_doc/jdeveloper/904preview/packaging_deploying/dbc_pldlibsappsvr.html

  • How to access all the classes in a jar file

    hai
    i have a custom built JAR file which has many classes(Translets) in it . i want to access the classes inthe JAR file in a JSP page or an servlet. I have tried setting the classpaths etc , but nothing has happened.
    Where should the jar file be Palced - i am using Tomcat Server.
    How Can i Access the class files .. Very Urgent .. Please Help me ..
    Peter Iyer

    What is showing a file not found error? The web browser? if so, that's probably not a problem with the jar file.
    Also, have you expanded your jar file to make sure that you jarred it up correctly?

  • Class Loader for Jar Files

    I have a set of Jar files which i need to load using Custom Class Loader. Any one who has Javacode for Custom Class Loader for loading Jar files send it. The Jar files are local jar files.

    Here is the class loader I use:
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.net.JarURLConnection;
    import java.lang.reflect.Method;
    import java.lang.reflect.Modifier;
    import java.lang.reflect.InvocationTargetException;
    import java.util.jar.Attributes;
    import java.io.IOException;
    * A class loader for loading jar files, both local and remote.
    public class JarClassLoader extends URLClassLoader {
        private URL url;
        private URL[] m_urlList = new URL[10];
         * Creates a new JarClassLoader for the specified url.
         * @param url the url of the jar file
        public JarClassLoader(URL url,ClassLoader cl) {
             super(new URL[] { url },cl);
          this.url = url;
        public JarClassLoader(URL[] urlList,ClassLoader cl) {
             super( urlList,cl);
          this.m_urlList = urlList;
         * Returns the name of the jar file main class, or null if
         * no "Main-Class" manifest attributes was defined.
        public String getMainClassName() throws IOException {
          URL u = new URL("jar", "", url + "!/");
             JarURLConnection uc = (JarURLConnection)u.openConnection();
             Attributes attr = uc.getMainAttributes();
             return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;
         * Invokes the application in this jar file given the name of the
         * main class and an array of arguments. The class must define a
         * static method "main" which takes an array of String arguemtns
         * and is of return type "void".
         * @param name the name of the main class
         * @param args the arguments for the application
         * @exception ClassNotFoundException if the specified class could not
         *            be found
         * @exception NoSuchMethodException if the specified class does not
         *            contain a "main" method
         * @exception InvocationTargetException if the application raised an
         *            exception
         public void invokeClass(String name, String[] args) throws ClassNotFoundException,
                NoSuchMethodException,
                InvocationTargetException
             Class c = loadClass(name);
             Method m = c.getMethod("main", new Class[] { args.getClass() });
             m.setAccessible(true);
             int mods = m.getModifiers();
             if (m.getReturnType() != void.class || !Modifier.isStatic(mods) || !Modifier.isPublic(mods)) {
             throw new NoSuchMethodException("main");
             try {
               m.invoke(null, new Object[] { args });
             } catch (IllegalAccessException e) {
             // This should not happen, as we have disabled access checks
    }

Maybe you are looking for

  • Do any one help me. I tried to install Oracel 8.1.5 on RedHat Linux 7.0 and failed.

    I am running my system with RedHat Linux 7.0 and tried to install Oracle 8.1.5. I extracted jre required files and when i tried to start ./runIns.sh from install/linux directory it is giving me an error Unable to initalize threads: cannot find class

  • Annotations are not read correctly

    Hi, I have the following sample Annotation package annotations; import java.lang.annotation.Annotation; * @author Stefan Schuster * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Te

  • Spry Horizontal Menu VERY SLOW

    I have a fairly simple spry horizontal menu that runs too slow. I am using a background image for the drop down wrapper. This doesn't seem to be the problem. There is no change when I use a solid background. The rest of the javascript on the page is

  • Help on achieving technicolor effect

    Hi guys, I am a little stumped and was hoping maybe someone had an idea to share. This should actually be relatively easy, unfortunately I'm at a loss for acheiving a similar vintage technicolor double exposure effect. An image attachment shows what

  • Logo in template header

    Hi all, i think i'm going crazy !!! Sometime ago i've tried to have a logo in the header getting image name and location from XML tag, no problem i've got it working using url.... in the image properties. Now i need to have the same feature on anothe