Do I always need to add .JAR to ClassPath?

My platform is Windows.
I pack my .class files to a .Jar file. When I want to use this .Jar, I always have to add it to ClassPath. I think it doesn't make sense. Does anything I can do that can make me use .Jar more convenient ?
Thanks

Can you elaborate more?
If you create an app and jar up all of the .class files in jar called myJar.jar for example, and then want to run that app, you just type in "java -jar myJar.jar" and its' not necessary to have myJar.jar in the classpath. (Remember to add a manifest with the Main-Class attribute defined! See java tutorial for more info on executable jars...)
If, otoh, you have a bunch of classes in a jar, and then want to refer to those classes from some other external class(es)/jar(s), then yes, you'll need to add that jar to your classpath.
-Ron

Similar Messages

  • How to add jar files  classpath in sun stdio creator

    Hi,
    i am using log4j-1.2.13.jar in my application.
    how to add it to my classpath in sun stdio.
    with regards
    shannu sarma

    Hi there,
    These threads will answer your question
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=61842
    http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=56060
    Thanks
    K

  • Add JARs to classpath within Java

    I've read through a number of different posts on this topic, but can't seem to get my code working.
    I want to write a class that will run embedded Tomcat. For certain reasons, I can't set the
    classpath to Tomcat before my class gets called, so I want to locate the Tomcat JARs, add them
    using a ClassLoader and then call the appropriate classes to setup and run Tomcat. An
    exception is being thrown, so I'm doing something wrong. Any ideas?
    Here's the code I'm trying to add the JARs with:
    String mcatHome = "tomcat/lib"
    try {
         // Scan folder for JARs and build URL array
         File mcatDir = new File(mcatHome);
         File files[] = mcatDir.listFiles(new JarFilter());
         URL jarURLs[] = new URL[files.length];
         for (int i = 0; i < files.length; i++)
              jarURLs[i] = files.toURL();
         // Add list of JARs to class loader
         URLClassLoader ucl = new URLClassLoader(jarURLs);
         // Use loader when loading classes
         Thread.currentThread().setContextClassLoader(ucl);
    catch (Exception ex) {
    then I call the contructor on the class which tries to start Tomcat:
         public void Mcat()
              startTomcat();
         protected void startTomcat()
              Embedded embed = new Embedded();
    When the constructor is invoked, I get:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/catalina/L
    ifecycleException

    jschell, the list of JARs is generated from listing them in the folder. I did print the list out and
    the URLs looked ok. (i.e. file:/....)
    Here a snippet of how the class calling is setup:
    In Runner.java:
    public void Runner()
         //code from original post to load JARs
         Mcat mcat = new Mcat()
    In Mcat.java:
    import org.apache.catalina.*;
    import org.apache.catalina.logger.*;
    import org.apache.catalina.users.*;
    import org.apache.catalina.realm.*;
    import org.apache.catalina.startup.Embedded;
    public class Mcat
        public void Mcat()
            startTomcat();
        protected void startTomcat()
            Embedded embed = new Embedded();
    }Hope this helps

  • How can I add jar files into the namespace in code?

    My friends:
    I need to add jar files into my namespace dynamicly in my code.But the jar files might be repeated, I am not sure.so, i wonder how can I add them into my namespace, ignoring the repeated files?
    This is my code:
    URL[] urlArrayA = new URL[5];
    urlArray[0] = sample1;
    urlArray[1] = sample2;
    URL[] urlArrayB = new URL[5];
    urlArrayB[0] = sample3;
    urlArrayB[1] = sample4;
    URLClassLoader urlClassLoaderA = URLClassLoader.newInstance(urlArrayA);
    URLClassLoader urlClassLoaderB = URLClassLoader.newInstance(urlArrayB);
    how can i visit classes in urlClassLoaderA from classes in urlClassLoaderB?

    could anyone please answer the question for me ? thank you...

  • Everytime i need to add a song in my i phone,it always ask for earse and sync option,i need to avoid that a add songs manually.

    everytime i need to add a song in my i phone,it always ask for earse and sync option,i need to avoid that and add songs manually.

    https://support.apple.com/kb/ht1535

  • List of .jar file need to add in web application by using eclipse europa?

    hi
    what are the list of .jar file need to be added in web application which use the ide of Eclipse Europa?

    Depends on the application requirements. For a basic JSP/Servlet application just integrate Tomcat in Eclipse and assign it as application server to your web project, then you don't need to add anything. If you for example need JSF, then you should add its JAR's to the classpath of the web project, which is by default /WEB-INF/lib.

  • How to add jar files to a project?

    What is the correct way to add jar files to a project?
    Jdev Help has an entry "Adding Files to a Project Using the Add Files or Directories Dialog", but when I goto File->Open as it says, there is no "Add Files or Directories" dialog.
    Using JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660 on Linux.

    That's not quite what I need, as it does not copy the files into the project, but just creates references to their original location in the filesystem. We want local copies so we can check the whole project into Subversion and not have external dependencies.
    Should I just copy the files manually (outside of Jdeveloper)? And what directory should I copy to?
    Thanks.

  • Add jar files and use those classes at the runtime

    Hi All,
    I need to add some jar files at the runtime depends on which the user selects where the jar file is located and i need to import those classes in other class for some functionalities . I could add jar files by using the URLClassLoader and Class.forName("myjar.myclassname") is also succeeded and i have no clue how to use those classes with in the jar file as i couldn't import those classes also in the source because the jar files are being added at the runtime(This leads to class not found exception at the compile time).
    I had found a complicated way of using those classes after being added at the run time as below.
       Class clazz = Class.forName(myClass);
                final Method method = clazz.getDeclaredMethod(requiredMethod, new Class[]{URL.class});
                final Object returned = method.invoke(clazz.newInstance(), new Object[]{request}); but, its really pain to use in this way in all the places.
    Does any of you have simpler suggestions on how to achieve this?
    Thanks,
    Venky.

    Thanks jschell. Yes, you are right. I had found that using reflection API is the only way to load classes at the run time. But according to our application using reflection makes the application little complex, so while start of the application or during other modifications, i am overwriting my jar file to the latest one using FileChannel class as below
          FileChannel ic = new FileInputStream("new.jar").getChannel();
          FileChannel oc = new FileOutputStream("old.jar").getChannel();
          ic.transferTo(0, ic.size(), oc);
          ic.close();
          oc.close();After this code is executed, our application totally uses the new jar file.It is little fast than using reflection. Is this a good idea?

  • My HD is almost full. I need to add space. Can I use an external HD to continue using my startup disc as it is?

    My HD is almost full. I need to add space. Can I use an external HD to continue using my startup disc as it is?
    I create music and have run out of space. the message says 'your startup disc is almost full', and i just thought maybe buying an external hard drive and using it as the startup disc or whatever would do the trick. Does anyone know? Thanks!

    External hard drives are relatively inexpensive...see some of those on OWC, www.macsales.com
    You can use a large external drive to provide additional space by simply saving material to that volume instead of the startup disk.  You can also partition the external drive to use part for Time Machine backups, and another partition for extended space.  Or a third partition for a clone of the boot system made by Carbon Copy Cloner or SuperDuper, both free downloads, so should the internal drive have problems you could always boot from the external partition.
    All of that can be done from Disk Utility.
    Keep in mind that Mac OS X gets very unhappy when there is less than 15% of the startup disk space free.

  • Jar files to add to the classpath for KM development.

    Hello Friends:
    I am trying to retrieve the favorites of the user stored
    under him home folder. In KM we have a readymade iview,
    called 'Favorites'. I am programmatically trying to
    read the values stored by this iview.
    I am using NWDS 2.0.5 on EP60SP2Patch3. When I use the
    following code,
    IUserManagementService umService = 
    (IUserManagementService) request.getService(IUserManagementService.KEY);
    // get the user object
      IUser user =
    umService.getDefaultFactory().getUser(userId);
    IResourceContext context =   new ResourceContext(user);
    in my IDE I get the following error:
    "This compilation unit indirectly references a missing
    type com.sapportals.portal.security.usermanagement.
    IUserFactory"
    The following are the jar files added to my project's
    classpath.
    com.sap.portal.usermanagementapi.jar
    com.sap.portal.usermanagementcore.jar
    com.sap.portal.usermappingapi.jar
    com.sap.security.api.jar
    com.sap.security.api.perm.jar
    com.sap.security.core.jar
    com.sap.security.core.tpd.jar
    apart from the usual portal framework related jar files.
    I tried also to add all the jar files with the prefix like...
    com.sap.km.*
    com.sap.netweaver.bc.*
    It didn't help.
    What are the other jar files I need to add, and where
    they are available.
    BTW, I unzipped all the 'portallibs' downloaded from the
    portal and using those jar files to attach to the project.
    Thank you very much,
    Prasad Nutalapati

    Hi Prasad,
    additionally you need com.sap.security.api.ep5.jar due to the fact that KM is using the old EP5 usermanagement libraries.
    Concerning the KM / RF libraries I would recommand to include all libraries matching the patterns bc._api.jar and km._api.jar
    Best regards,
    Thilo

  • How to add JAR files in JDeveloper 10.1.2

    Hi,
    We have developed a J2EE project using JDeveloper. Now, i have to add Upload CV functionality to the application. I want to use the classes provided by org.apache.commons.fileupload which is there in the commons-fileupload-1.2.2.jar file provided by them. My problem is i am unable to add this JAR file to my project. When i try to add this JAR file using the Project Properties of my project. Its asking me to browse the path of the J2SE Executable or EDIT the Class Path or Source Path or Doc Path. There is not option to add JAR files. If the JAR file is not added, its showing the errors:
    imported class 'org.apache.commons.fileupload.disk.DiskFileItemFactory' not found exception..
    Please let me know how i could associate JAR files to my project so that the upload files functionality is implemented. Will be desperately waiting for any assistance....
    Regards,
    Najmuddin

    Thanks John, that was helpful. After i added the JAR file, its showing me the following error:
    Error(479,16): class FileUploadException not found in class htdocs.recruitment._regMain.CommonsFileUploadServlet
    Is there any specific location where i need to keep my JAR file or i can browse it from anywhere?
    Regards,
    Najmuddin

  • Is there a way to add jar file in my program

    sorry to botter you, but i really need help for this, i really dont know how to do it. i have my prog taht i want to put in jar file, that cause no problem, but my program isnt fully functionnal because he use a jar file (my driver to acces my database) taht i had mount in forte. but i cant put in in my class file, because i want my jar to be able to run everuwhere on any computer taht have the jre installed. so in resume, i want to add jar file in my program... can i have to add it in my jar file, or decomrpesse it and put the folder like org.postgre.mfileshere... ????? i really dont know
    thx to help me

    ok If I understood, you need to add a third part Jar
    file to your own Jar File App so...
    Yes, you can decompress it in a directory tree and
    merge it with your application (i.e) if you have a jar
    file like this:
    br.com.yourApp.util
    and a third part jar file like this:
    br.com.thirdPart.tools
    br.com.thirdPart.util
    you will have these directory trees:
    br/com/yourApp/util/
    br/com/thirdPart/tools/
    br/com/thirdPart/util/
    then you can marge it in a unique tree:
    br/com/yourApp/util/
    ....../thirdPart/tools/
    ................/util/
    then you can make a new jar file with it...
    .....OR YOU CAN ADD THE PATH where your JDBCDrive is
    placed to the classpath of your application just using
    the -classpath option execution string of you
    application, like this:
    C:\jreHome\bin\java.exe -jar -classpath
    .;C:\someDir\thirdPart.jar yourApp.jar
    That's the better way to do it and then everything
    will work! :-)
    []'s Igor
    Brazil * * * * *k thx, ill give a try, and give you result later. but can you answer me another question, why when i double click on any jar file executable, sometimes javawa start but do nothing, sometimes they start and said no main class find, sometimes dotn start anymore, and sometimes work perfectly...?? is the jdk taht is not good? i use the last one
    or problem with my instalation, or the prog i try to run?
    thx

  • AVCHD clip's always needs to get rendered when inserting. Media info about .mts file attached

    Hi
    I have previously discussed this problem in another thread. I have .mts files that I insert in a project (project preset set to PAL-AVCHD Full-HD)....when inserting i always need to render the clips and as many peole have mentioned, this should not be needed, instead PrEl should take care of this by itself..and it really sunds weird if it doesnt...
    So, why is this happen...i get so frustrated when I have to re-render the clips all the time, since also - it takes a looong time for jsut tiny tiny clips ? I posted the hardware specs I have two days ago in this same forum, and it looks from the answers I got that this hardware should be enough for not having to wait several minutes to jsut add a 6 second AVCHD clip ?
    Please look at below image that is a screenshot from MediaInfo about the details for my .mts file I'm trying to add - resulting in new rendering needed, plus the fact that it takes about 5 minutes to render it ??
    Please, suggestion or solutions ? I'm lost...I got feedback yesterday that this is a known problem with both PrEl 8 and PrEl 9 ..that AVCHD clips needs to get rendered manually when they are added....i.e a known bug in these versions ?? Any experience ? How can I move forward, I have problems to understand that such bug should exist without anysolution and/or workaround since I see this as a feature that MUST work for people not getting crazy :-)
    MediaInfo screenshot (click on image to get it to look better) BR /Helmut

    Hi Neale
    many thanks for your time trying to help me out.....
    Please see my answers below in bold, hope you and/or someone else can help me with some further answers
    Are you opening a project created in PRE8 with PRE9? If yes, that is the most likely cause of the problem. Create a new PRE9 project and see if the same problems after you import the clip and save the project. No, I'm only working in Pr 8.0 - I have this problem as soon as I add a clip..not that into the different formats, just know that the best possible output from my camera (Canon HF10) should be AVCHD..thats why I added teh detailed info from "MediaInfo". can you tell from that info I'm correct, i.e that the .mts file is really AVCHD as expected ? Just to help me confirm that. So, I havent been using PrEl 9.0...another person two days ago told me that PrEl 9 also got similar problems as I reported for my PrEl 8.0 ?
    When you first added the clip to your project did you receive any messages that the file was not suitable for the format? If so did you accept the offered preset? If you didn't start a new PRE9 project and this time accept the offer. No, I did not get any messages as all about the format. Occasionally I get something like "Do you want to fix the quality in the clip" ..cant recall exactelly what the message is, but its for sure nothing about the format
    When you put it into the project, did you have a red line running the length of the timeline? If you do then your preset is not correct (this is purely PRE9. PRE8 always required rendering AVCHD footage).Yes, always when I add a clip I get this red line. If I understand everything correctly this means I have to hit ENTER key to create a preview file....thats my second problem - as soon as I do that, it renders the clip very very slowly although I should have prety good hardware (According to spec posted two days ago).
    So, as a summary. Do you think that buying Premiere Elements 9.0 should get rid of this problem when adding AVCHD ? If that is the case, I feel I just want to be sure about this and that I will not experience the problem again. Can it not just be some setting that is, by default, not correct in Premiere El 8.0 that is causing this or is this really a known bug without fixes available from Adobe?
    Best Regards
    Helmut

  • How to Add JAR files and Config files to CLASSPATH at runtime?

    QUERY:
    During runtime, I need to load the JAR files and relevant config files( .cfg files and .properties file) into CLASSPATH and run a specific java program from one of the JAR which is available in CLASSPATH.
    Please advise me any relevant Java API details or a sample java program to implement the above use case.
    Thanks in advance.

    During runtime, I need to load the JAR files and relevant config files( .cfg files and .properties file) into CLASSPATH and run a specific java program from one of the JAR which is available in CLASSPATH.
    Please advise me any relevant Java API details or a sample java program to implement the above use case.
    You don't add to YOUR classpath once your app is launched.
    You create a NEW process for the app you want to run and provide the proper environment for it to run in - including any PATH or CLASSPATH environment variables.
    The Java API for the ProcessBuilder class has a simple example that shows how to create the arguments and launch an external application.
    ProcessBuilder (Java Platform SE 7 )
    There are also PLENTY of other examples of using ProcessBuilder; just search the net.

  • Need to add WinXP to system

    I'm currently running Mountain Lion on a 2TB, single partition hard drive.
    I need to add a WinXP partition.
    Mountain Lion's Bootcamp Assistant only supports Win7.
    How can I add a WinXP?
    Thanks
    -Mike
    P.S.
    For those on this site who love a mystery, here's one for you.
    And for those who can solve it, you'll have my eternal gratitude.  :-D
    I've attempted going back to Snow Leopard (which is the OS that came on my system when I bought it from Apple 2 yrs ago.)
    However, when the install process gets to the point where I choose the disk to install SL on, the installer shows an exclamation icon over it and a message in the installer window says "Mac OS X cannot start up from this disk."
    What!?!?  This is my one and only startup disk and am always starting up on it.
    Ideas?

    Thanks Allan and Bob. You've both confirmed my suspicions and helped me decide on a solution.
    Here's my theories:
    1) In order to maximize efficiency, Apple has chosen not to support WinXP in Lion and later Bootcamp solutions. Otherwise, they would have to provide XP drivers for all of the hardware options available in addition to drivers for Win7, perhaps forcing them to supply and maintain several DVDs. I understand this thinking. I'm thinking that this may be why ML Bootcamp Assistant only supports Win7.
    2) I then thought, well, I'll simply add an additional partition to the end of my HD using Disk Utility and install XP on that new partition formatted as FAT32. I'd then insert my XP disk, boot into that disk upon startup using the Option key and then choose this new partition for the install when the XP installer requests that I choose an install partition. The problem I discovered in this situation is that XP cannot see that last partition, precluding me from choosing it as an option for the install (Remember I'm installing onto a partition located at the end of a 2TB drive). Perhaps the XP installer was not built to even detect partitions located at this distance on such a large drive.
    This seems to indicate that Bootcamp Assistant for Snow Leopard must provide some mapping scheme when it partitions these large drives that allows XP to see this distant partition during the install process.
    3) Ok, I then figured, I'll simply run Snow Leopard's Bootcamp Assistant in Mountain Lion and create and install XP that way. Well, it turns out that SL's Bootcamp Assistant gets confused about the partitioned setup in Mountain Lion and issues a message stating "The startup disk cannot be partitioned or restored to a single partition". This seems to indicate that ML has altered the partition information on the HD in a way the confuses SL's understanding of it.
    4) Finally, I attempted to simply re-install SL by inserting the original DVD supplied with my iMac into the drive, rebooting into that DVD upon startup and then installing from this DVD. Well, this produces the result I described in the P.S. in my first post in this thread.
    Well, those are my theories at this point. Any further clarifications or rebuttals?  :-D
    I think I'll try either Allan's or Bob's (or both) solutions next.
    Thanks again.
    -Mike

Maybe you are looking for

  • Question on schedule jobs

    Hi, i created two varients of the job as shown belo. 1) DECLARE   X NUMBER; BEGIN   SYS.DBMS_JOB.SUBMIT     ( job       => X - job name as 'X'      ,what      => 'DEL_EMPLOYEE_TABLE;' - ITS A STORED PROCEDURE      ,next_date => to_date('19/05/2009 01

  • SAP Best Practice for Plant Organizational Structure

    Hi Can one please suggest us . how we can design the Plant Structure ( Please refer OSS notes if you have ). 1) Design of a Plant / Storage location if it is located in  different state. We have one manufacturing plant , and six storage ware house in

  • Canon 1 D mark III announced - now you need LR stacks 10fps - 110 jpeg burst.

    Canon 1 D mark III announced - now you need LR stacks 10fps - 110 jpeg burst. See LightroomExtra RSS feed or www.sidjervis.com blog page. Key features 10.1 Megapixel APS-H CMOS sensor 10 fps continuous shooting for up to 110 frames Dual DIGIC III pro

  • LCDS/FDS integration with SAP

    I have installed the LiveCycle Data Services ES along with Adobe Flex 2. We use SAP as our backend system. I tried implementing the steps mentioned in http://help.adobe.com/en_US/livecycle/es/lcds_installation.html for SAP NetWeaver. Although my depl

  • Running osx on regular pc

    Hi, I would like to purchase osx and i want to know if it can be run on a regular pc without using different tools on the internet, just put the cd in and install. My pc specs: CPU : AMD FX6100 ( Six Core ) 3.3 Ghz RAM : 8.0 GB Video Card : Gigabyte