Can't access class files in jar file

I'm running Eclipse and trying to access class files in a jar file from source. I have added the jar file through Properties/Java Build Path/Add External JARs... but the class files are not visible from my source code. Any ideas what is happening?
Thanks!

Depends what you mean by "visible." Are you getting a ClassNotFoundException? If so, your JAR isn't in your runtime CLASSPATH. You should be able to solve that (in Eclipse) by by modifying your project classpath.
If "visible" means your code is usng a ZIP class to peek inside the JAR & it's not working, best bet is to re-study the ZIP class Javadocs & examine the error messages carefully.
If this doesn't solve the problem, please provide more details & the specific error message/stack trace you're getting.

Similar Messages

  • 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 can I access EJB  through executable jar file?

    Hello buddies!!
    I wonder if anyone could give me an explanation of how accessing EJB through executable jar file?Thanks!!

    Hi there,
    You'll need to install the J2EE SDK on the client and include the <j2ee install dir>\lib\j2ee.jar file in your CLASSPATH along with the Client Jar file that was generated by the deploytool when you deployed the application.
    In your client code the Context properties are as follows:
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
    p.put(Context.PROVIDER_URL, "iiop://hostname:portnumber");
    Context cntx = new InitialContext(p).Hope this helps
    Amanda
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers

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

  • Trying to access the java script files via jar file in WEB SERVER

    hi all,
    I am trying to access the java script files via jar file ,which is present in Apache webserver in order to minimise the number of hits to app server.some thing like cache ...
    in jsp the code goes like this...
         <script type="text/javascript"  archive="http://localhost:14000/dojo.jar!" src="dojo.jar/parser.js" " ></script>{code}
    But i am not able to access the js file which is put in jar file present in the  webserver.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    You can use DWR (Direct Web remoting) for that. It is easy AJAX for java. ou can directly call the java script function from java class and also java class from javaScripts..
    Regards,
    Hardik

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

  • Don't know how to make my main class import a jar file

    OK, the title doesn't make much sense but here are my create-jar.bat and manifest files:
    create-jar.bat:
    jar cvmf manifest.txt dassimul-admin.jar player/ admin/ com/ connector/ common/ *.class
    manifest.txt:
    Main-Class: admin.DASAdmin
    the problem is that in connector/ folder there is the jdbc mysql connector driver (.jar file).
    in Eclipse I can add this jar to the Java Build Path, so the program runs.
    When I double-click the dassimul-admin.jar file, I get a Class Not Found Exception
    C:\MYWORK\dassimul>java -jar dassimul-admin.jar
    FATAL ERROR WHILE LOADING SQL DRIVER: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    I think that the problem lies in the fact that admin.DASAdmin can't see and import the jar file in connector/ folder... am I right?

    It looks like you are putting the mysql jar file inside the dassimul jar. That won't work unless you write custom code. You should use the Class-Path attribute of the manifest to define a relative path(s) to the other jar(s) that you need to use.
    [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]

  • How to get the class file of jar file

    hello all,
    is there any way to get the class file of jar file,as we have when we compile a java file we get class file
    same do we have any option to get the class file of jar file

    A jar file is a zip archive, so you can uznip it or extract the contents with the command "jar" - if it is what you need.

  • Can't start RMI server using JAR file

    I found it interesting that if I start my RMI server from
    a plain directory, everything goes fine.
    But if I jar all these necessary files into a jar file,
    and start my RMI server with command below
    java -jar server.jar
    UnmarshalException and ClassNotFoundException are
    thrown to indecate that my stub class can't be found
    (which I'm sure my stub class is in jar file)
    Why is jar file so special that it can't act like
    what it originally does when it hasn't been jared?
    or I really should take care of some configuration
    before I really can run a jar file?
    thanks

    To clarify few things...
    What I don't understand is that when I convert all my
    directories and class files properly into the jar file, they
    just can't work properly.
    I don't know if it's a problem of JAR file,
    or it's RMI that make this JAR file special?
    I'll simulate my JAR file structure that listed below,
    these structure works fine when they have'nt been
    converted into JAR file.
    META-INF/
    META-INF/MANIFEST.MF
    a/b/x1.class
    a/b/x2.class
    a/b/c/Y.class
    a/b/c/Y_Skel.class
    a/b/c/Y_Stub.class
    And when I use command "java -jar server.jar"
    to run my application, ClassNotFound exception
    is thrown to indecate my stub class is not found.
    Is there anything I can do to correct this?
    thanks

  • Can FTP-access to field point log file interrupt the running program?

    Can FTP-access to field point log file interrupt the running program?
    We have a problem where our factory process control program on a Field Pointer suddenly stops the process. We are running the development system on a PC, wich deploys the program on the Field point, with user interface on the PC. Quite often the process stops for no apparent reason. I'm not sure right now if the control program on the Field Point is still running or if it stops. We use FTP from a distant PC (over VPN) directly to the Field Point to check if the process is running, by looking for date and size of log files produced during running process. I've never opened och copied any log file during process run, because this I'm sure this would cause problems for new log entries to be written. But can the mere looking at the log folder via XP-pros ftp-functionality cause the Field Point to have problems writing data to a log file?
    I'm not sure how windows XP pro handles "my network places" when it comes to FTP, it look that it keeps some kind of local copy of the folders, or at least the files opened.
    Next version of the program will have only basic functionality on the Field Point, leaving logging etc. to another program on the PC, but right now we are stuck with this system.
    Ola A

    It turned out that the problem lies in the harware of the production machine, it was not a labiew-program problem at all!
    Ola

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

  • 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

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

  • Since downloading firefoz 4, everytime I make a browser search I get a second page with :"Firefox can't find the file at jar:file://how can I solve the problem. Kindly reply to :ramses1@videotron.ca

    Question
    firefox 4, when I make a browser search I get a second page:"Firefox can't find the file at jar:file:///D:/Program Files/Mozilla Firefox/omni.jar!/chrome/browser/content/browser/<url></url>", how can I solve the problem.

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • I upgraded to Firefox 8. Now my home page says this: "Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/browserconfig.properties.

    This is what it says on my screen when I open Firefox:
    Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/browserconfig.properties.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

Maybe you are looking for

  • Report taking more time to format in PDF

    Dear All I have developed report in oracle reports bulider 10g. while running it from report builder data is coming very fast. But, If it is running from parameter form it is taking too much time to format report in PDF. Please suggest any configurat

  • Will upgrade to mac pro 2010 give huge improvement from mac pro 2006?

    I asked in an earlier post but may not have been clear. Basically, if I upgrade to a new mac pro 2010 quad core 2.8 GHz (12GB ram) will it give me a huge improvement from a mac pro 2006 2.0GHz (with 5GB Ram) and thus reduce the need to render and the

  • Vertical Toolbar thingy with a search field and my bookmark folders underneath. How do I get rid of it?

    This might sound ridiculous but here it goes: I accidentally hit a couple keys on my netbook keyboard. This made a toolbar pop up on the left side of the window. It's vertical and has a search field at the top, then listed underneath are my bookmark

  • Installing Windows 7 via Bootcamp with OS X Lion

    Hi all, I have just bought a new 21.5 inch iMac preinstalled with SL and have the Install DVD for 10.6.7. I have recently upgraded to Lion OS X (eligible for free download due to recent purchase of the iMac), but now want to install Windows 7 via Boo

  • No Predicate Information showing in typical display

    same sql statement, in other environment, when I display plan with dbms_xplan, it shows predicate information, only in one environment, not showing, even I used ALL option, compared two environment, there is no difference, what is could be possible r