Is it possible to run a jar file in another program???

Hello members,
i am sanketh. is it possible to run a jar file in another program.
if possible plz reply with an example or good links to go thru.

What do you mean "run a jar file in another program"? It's not very clear.

Similar Messages

  • Is it possible to run a JAR?

    My high school Computer Science teacher thinks it might be possible to run a JAR file in windows and have it run the java program (command promt type) in windows. I do not believe this is possible but he wanted me to check and see.
    Also is there any other way to run a java program in the form of class files without going through the DOS prompt or a compiler? Duke dollars if you know a way.

    when you install the JRE it should associate jar files
    with the JVM, hence double-clicking on them will run
    them. but....well... strictly they become associated with javaw
    to make a jar an executalbe jar it needs a
    'main-class' attribute in the manifest. That is make
    a directory that goes in to the jar called META-INF
    and in there a file called manifest.mf (just a plain
    text file).thought i had already mentioned that!
    test from the command line with
    java -jar myjarfile
    or
    javaw -jar myjarfiledouble-click issues an identical command - if it doesn't work one way then it won't work the other
    the difference between the java and javaw is that the
    javaw will not open a DOS window. true!

  • Executing .jar files from another .jar file.

    How would I run one .jar file from another .jar file. and is there anyway to call specific class arguments? Because I have one .jar file that reads a specified file and returns its contents.
    So how would I execute it and specify its arguments and how would I make it return something to the executing jar file?

    Because I have one .jar file that reads
    a specified file and returns its contents. Presumably you have a class that does that, and you have that class stored in a jar. And you want to know how to... um... do something with that class. I say "um..." because normally you don't execute a class, either, you either call its static methods or you create an instance of the class and call its instance methods.
    If you have been writing a whole lot of little classes each of which just has a static main method, then stop doing that. Write real Java classes instead. The tutorial is here:
    http://java.sun.com/docs/books/tutorial/java/index.html

  • How can i run a jar file as EXE on mouse click..

    *{color:#0000ff}how can i run a jar file as EXE on mouse click..is it possible in any way?????????{color}*

    amrit_j2ee wrote:
    *{color:#0000ff}how can i run a jar file as EXE on mouse click..is it possible in any way?????????{color}*Do you mean converting it from a jar file to an EXE file or do you mean that you would like to run the application by just double clicking it?
    If it's the latter then you need to make the jar file including a manifest.
    The manifest can be just a txt file with its content to be something like this:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: Somebody
    Main-Class: NameOfTheMainClass
    Class-Path:
    X-COMMENT: Main-Class will be added automatically by buildTo make the jar file including the manifest, use something like this in your command prompt (of course you must have compiled your java file(s) first):
    jar cfm test.jar MANIFEST.txt NameOfTheMainClass.classAfter that you'd be able to run your application just by double clicking it.
    If you're a NetBeans user, you can build your standalone application by right-clicking your project and then going to properties => run => and choosing a Main class. After that right click on that project and "Clean and Build", locate the jar file in the "dist" folder and double click it =]
    Hope it helps,
    LD

  • Html script to run a Jar file

    Is it possible to automatically run a .jar file from an .html page? Here is my issue:
    I have a software script for athletes that runs from a jar file. I need to create an index.htm file in order to use the compiler software that I am using.
    So I am trying to figure out if there is a script to put in the index file that will immediately run the main .jar file. I don't want the viewer (athlete) to even see the index file so the only code I will put in there will be to run the .jar file.
    Is this possible?
    thank you!

    This all sounds very confused.
    There are applets (Java applications embedded in a webpages).
    There are stand alone applications (Java applications that are by themselves no web page required)
    There are servlets ( Java applications that produce HTML pages [and other web content])
    This bit about my compiler needs it makes no sense. And I don't know which of the above you have or are trying to be honest. I will tell you this, it is one of them (probably the first two).
    So which one of those are you trying to make? If you say none of them then please think harder because that is not a valid answer.

  • Run a jar-File and modify a file within this jar-File

    I am running the jar-File, which contains my compiled java files etc.
    The program has a config part, which is saved in xml file.
    This xml file is in the same directory like the class files.
    All theses files are zipped as jar-File.
    Well, I am running the jar file.
    - But how do I open and save the xml file ?
    - Is that possible ?
    - How difficult ist that ?

    I tried to do this some time ago and found out the hard way that you can't, just as DrClap just told you. I would have taken his work for it anyway, but for what it's worth, I thought I'd mention that you're not alone. In my case I wanted to be cute and keep my properties all together within the .jar; thought it'd be cleaner that way. Ended up just creating the more typical class_name-props file in my home directory. Is this what you had in mind?
    ~Bill

  • How to run a jar file in a browswer?

    Hi, everyone:
    I got a problem here. I would like to run my jar file in a html-based brower, should I write another applet for my jar file? How can I do that? (I don't have applet in my jar file, but only JFrame) Is there any way I can put a runnable jar file into an applet and show on the brower? Could anyone show me how to write this code? Thank you very much!!
    -jxchou

    At first you need a java plug-in for your browser.
    Next you have to implement an applet in your jar-file.
    The tag in your html-document should look like:
    <applet code="Sample.class" archive="sample.jar" width="400" height="400"></applet>

  • How to run a jar file in JBuilder

    Hi there
    I need to know how to run a jar file using JBuilder. Thanks :)
    Countess

    well i have a german version of jbuilder and there it is under
    experten Archiv-builder
    look at something that has a similar name

  • How to run a JAR file in Unix system?

    hi there
    ca anyone tell me how to run a JAR file in unix system or X window, thank you

    You want to create an executable JAR file? You do it in the following way.
    Create a manifest file such as manif.txt and the contents should contain
    Main-Class: foo
    assuming foo is the name of your main class. Then create the jar as follows
    jar cvfm foo.jar manif.txt foo.class
    I hope that helps you!
    you can find more info here http://java.sun.com/docs/books/tutorial/jar/

  • OutOfMemory Exception while running a JAR file

    Hi,
    I am working with Java 1.5 and using Eclipse to build a GUI. My application has intensive image loading involved so I set -Xmx inside Eclipse when running the application in debug mode.
    However, once a JAR file is exported, I do not know how to specify the heap size required to run the program. Is there a way to ...
    1. embed the heap size info inside the JAR file?
    2. specify a heap size when running the JAR file?
    Thanks in advance.

    Heap size is specified by the -Xmx option on the java command. See the java command documentation.

  • Running a jar file from java code

    Hi!
    Im trying to run a jar file from my code.
    I've tried Classloader, but that doesnt work because it doesnt find the images (also embedded in the 2nd jar file).
    WHat I would like to do is actually RUN the 2nd jar file from the first jar file. There must be a way to do this right?
    any ideas?

    ok, I found some wonderful code (see below) that will try to start the jar. But it doesn't. What it does is produce the following error when my application runs...
    So it's not finding the images in the jar file that I am trying to run? Strange. I checked the URL that sending, but it seems ok....
    I think I will check the url again to make sure......
    any ideas?
    Uncaught error fetching image:
    java.lang.NullPointerException
         at sun.awt.image.URLImageSource.getConnection(Unknown Source)
         at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
         at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
         at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
         at sun.awt.image.ImageFetcher.run(Unknown Source)
    the code....
    /* From http://java.sun.com/docs/books/tutorial/index.html */
    import java.io.IOException;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.lang.reflect.Modifier;
    import java.net.JarURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.util.jar.Attributes;
    * Runs a jar application from any url. Usage is 'java JarRunner url [args..]'
    * where url is the url of the jar file and args is optional arguments to be
    * passed to the application's main method.
    public class JarRunner {
      public static void main(String[] args) {
        URL url = null;
        try {
          url = new URL(args[0]);//"VideoTagger.jar");
        } catch (MalformedURLException e) {
          System.out.println("Invalid URL: ");
        // Create the class loader for the application jar file
        JarClassLoader cl = new JarClassLoader(url);
        // Get the application's main class name
        String name = null;
        try {
          name = cl.getMainClassName();
        } catch (IOException e) {
          System.err.println("I/O error while loading JAR file:");
          e.printStackTrace();
          System.exit(1);
        if (name == null) {
          fatal("Specified jar file does not contain a 'Main-Class'"
              + " manifest attribute");
        // Get arguments for the application
        String[] newArgs = new String[args.length - 1];
        System.arraycopy(args, 1, newArgs, 0, newArgs.length);
        // Invoke application's main class
        try {
          cl.invokeClass(name, newArgs);
        } catch (ClassNotFoundException e) {
          fatal("Class not found: " + name);
        } catch (NoSuchMethodException e) {
          fatal("Class does not define a 'main' method: " + name);
        } catch (InvocationTargetException e) {
          e.getTargetException().printStackTrace();
          System.exit(1);
      private static void fatal(String s) {
        System.err.println(s);
        System.exit(1);
    * A class loader for loading jar files, both local and remote.
    class JarClassLoader extends URLClassLoader {
      private URL url;
       * Creates a new JarClassLoader for the specified url.
       * @param url
       *            the url of the jar file
      public JarClassLoader(URL url) {
        super(new URL[] { url });
        this.url = url;
       * 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
    }

  • Unable to Run a .jar file in pjava

    I have installed pjava (for StrongArm) on to my iPAQ Pocket PC H3660.
    Then I created a simple application using JBuilder and created a *.jar file of the classes. I have used the awt classes to build the interface. I am using JDK version 1.3.0.
    When I deploy it into my Pocket PC and run the jar file, the compiler loads up and I get the error message "Cannot find class : packagename.classname".
    I have checked the jar file contents in JBuilder and the class files are all in there.
    Could anyone help me on this? Thanks!

    If you are compiling with JDK1.3 (or any compiler > java 1.1.8), you have to use the parameter "-target 1.1" to make sure the class files will be loaded by a 1.1 JVM. Jeode doesn't seem to care about this setting, but when we switched to Creme the problem arose.
    -Eric

  • Run a JAR file!!!

    How to run a JAR file....

    you need to specify the
    Main-class: your class contains main method here
    attrbute in Meta-inf
    nd you can run usinf
    java -jar yourjar.jarThe question was not, "How do I create a manifest file that will allow me to run my jar file?" It was simply, "How do I run a jar file?"

  • Is it possible to verify a signed jar-file from a program?

    Is it possible to verify a signed jar-file from a program
    (using some API) likewise jarsigner does?

    Is it possible to verify a signed jar-file from a
    program
    (using some API) likewise jarsigner does?Hi,
    You would have to open the jarfile, read each jar entry and for each of them do a getCertificates() and then in turn verify each certificate with the public key of the enclosed certificates in the jar file.
    An easier solution would be to use the verify flag of the JarFile or JarInputStream.
    Hope it helps..
    Cheers,
    Vijay

  • Getting error when running the jar file..

    Hi All,
    I am new to executing jar file..Actually i have one class which contains the following code.
    import com.documentum.fc.client.DfClient;
    import com.documentum.fc.client.IDfClient;
    import com.documentum.fc.client.IDfSession;
    import com.documentum.fc.client.IDfSessionManager;
    import com.documentum.fc.common.DfLoginInfo;
    import com.documentum.fc.common.IDfLoginInfo;
    import com.documentum.fc.common.DfException;
    import com.fidelity.ftg.ereviewg2.migration.util.MigrationResource;
    * This class is used for creating docbase connection
    * *@type* DocbaseConnection
    * *@author* a405304
    * *@see*
    public *class *DocbaseConnection {
    //public static ResourceBundle resource;
    IDfSessionManager sMgr = *null*;
    IDfSession session = *null*;
    String docbaseName;
    *private* *static* DocbaseConnection +docbaseCon+;
    * Constructor for DocbaseConnection
    * *@throws* DfException
    * *@throws* Exception
    *private* DocbaseConnection()*throws* DfException, Exception{
    //ResourceBundle bundle = ResourceBundle.getBundle(Constants.RESOURCE_PATH,Locale.getDefault());
    MigrationResource bundle = MigrationResource.+getBundle+();
    String userId = bundle.getString("DOCBASE_USERID");
    String password = bundle.getString("DOCBASE_PASSWORD");
    docbaseName = bundle.getString("DOCBASE_NAME");
    IDfClient client = DfClient.+getLocalClient+();
    sMgr = client.newSessionManager();
    IDfLoginInfo loginInfo = *new* DfLoginInfo();
    loginInfo.setUser( userId );
    loginInfo.setPassword( password );
    loginInfo.setDomain("");
    sMgr.setIdentity( docbaseName, loginInfo );
    session= sMgr.getSession( docbaseName );
    System.+out+.println("# Connected to Docbase: "+session);
    }Now i create the jar file whose name is docbaseconnection.jar
    Now when i am running this jar file by using the following command then i am getting the following error..
    C:\JAR_FILES>java -jar docbaseconnection.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: com/documentum/fc/client/DfQuery
    For running this docbaseconnection.jar file i need the following thing in classpath...
    C:\Program Files\Documentum\dctm.jar;C:\Program Files\Documentum\Shared\dfc.jar;C:\Program Files\Documentum\Shared\log4j.jar
    I already add this jar files in the classpath of environment variables..Then also i am getting the same error..
    Kindly help me...........

    Well, let´s supose your manifest is defined as I did in my previous post. So, your directory base should be something like:
    C:\dir
    docbaseconnection.jar
    dctm.jar
    dfc.jar
    anotherlibraries.jar
    But, let´s supose you want something like
    C:\dir
    docbaseconnection.jar
    lib (folder, which contains dctm.jar, dfc.jar, etc)
    Then you should change the class-path of your manifest to
    Class-Path: ./lib/dctm.jar ./lib/dfc.jar
    That´s what I meant

Maybe you are looking for

  • Boot camp on an external hard drive

    Is it possible to use bootcamp and run windows on an external hardrive rather than the built in one with out sacrificing speed. Im looking to get a hard drive for all my windows stuff and I was hoping to be able to run windows straight from it but I

  • Stretched text and image with FULL_SCREEN_INTERACTIVE after Air player update

    One of my Air applications uses StageDisplayState.FULL_SCREEN_INTERACTIVE to switch to full screen during the presentation of some sheets. Everything worked fine untill some users reported a streching of texts and images in the sheets. It turns out t

  • Trying to create ebay template, designed in fireworks, when i import to dreamweaver i carnt edit

    hi, i am creating an ebay template and i have designed the boxes and banner i want etc, when i import it into dreamwaeaver i carnt edit it, its like an image, i have sliced it and imported the html i dont hasve much experiance with dreamweaverr, i wa

  • Ios7 clearly not optimized for ipad2

    that I'm allowed to update my ipad2 to ios7 should mean that it will run properly. It takes literally 10 seconds for each letter, to type in a web address in Safari. I did a soft reset, same result. Apple clearly released this update without checking

  • How connect 10g with discoverer (host name give me error)

    hi master sir i install discoverer but not connect with oracle 10g i flow this step 1. From the Start button use Programs | Oracle - BIToolsHome1 | Configuration and Migration Tools | Net Configuration Assistant. 2. Select Local Net Service Name Conf