Help with running java .jar file

Hi I just installed java with
# pacman -S jre
and when i try to run
java -jar file.jar
it says command not found. so what do i need to install to be able to run java .jar files through the CLI?

do, what vintendo says. because it cant find the java in the default paths.

Similar Messages

  • How to run java jar file

    Hello,
    I got a java jar file which contains folders with class file. When I double click on the jar file, it gave a error
    Exception in thread "main" java.lang.NoClassDefFoundError
    How can I run this jar file?
    Thanks,
    CR

    Hello,
    I got a java jar file which contains folders with
    class file. When I double click on the jar file, it
    gave a error
    Exception in thread "main"
    java.lang.NoClassDefFoundError
    How can I run this jar file?
    Thanks,
    CR... and assuming that Jar contains a manifest file, what does it look like? I would guess that the Main-Class entry is incorrect, or that the Jar has external dependencies to other jars not listed properly in the Class-Path entry.

  • Help with creating a jar file

    hi sorry if this is not the place to post the topic but was not sure where to post it.
    i have make an application that has some images and a database but i would like to make a "exe" or somthing so that the client dose not have to open an ide and click run. they can just double click on somting. am not sure about how most of you distrbute your apps. can you help me please.
    the client will be useing windows 95.
    i know that a jar file can do this but i am not sure on how to change the refrences in the code to include the images and every thing. and how would i go about getting it into jar form
    thanks nibur

    You can create an executable jar.
    Note that even if you do this, the user will need to have a JRE installed on their machine for this to run.
    Here's how you can make this executable jar:
    Replace all code that refers to the filesystem (like if you do "File f = new File("c:\myDirectory\file.txt");") to use resources:
    http://java.sun.com/j2se/1.4.2/docs/guide/resources/index.html
    Create a manifest file that has a Main-Class: attribute.
    Then use the "jar" tool to create the jar:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/jar.html
    That doc has "see also" links at the bottom that can tell you about executable jars and manifest files.
    If you're using an IDE, the IDE probably has a tool to create jars for you. In Eclipse, it's under File -> Export. Check your IDE's docs for details.

  • Help with classes in .jar file

    Let say, there are additional classes in a .jar file
    How can I add it to my java program so that it can be recognized/used in the java program?
    Need response asap. by Today. TQ

    help...jar... wrote:
    Let say, there are additional classes in a .jar file
    How can I add it to my java program so that it can be recognized/used in the java program?
    Need response asap. by Today. TQClasspath.

  • Open console when i run java jar file

    greetings all
    i have a java program that i execute through JCreater. i want if i make its JAR file then its console should be open so that i could see thats printing when i use "System.out.println". is there anyway? right now when i double click my JAR file then nothing is displayed. how can i make that happen?

    thx flounder
    you see i need to see whats printing through my System.out.println() command. I am working on JCreater at the moment. when i execute my program an output window is opened, it displays whatever i have written in System.out.println. now i want to make an executable JAR of my program and also want to see my output window. is there any way to do that?

  • [SOLVED]Java error running a .jar file

    Hi. I'm running Arch 64 and I keep getting this error when trying to run
    java -jar TwinkEdit-0.6.9.jar (from twinkle.sourceforge.net -- a flashcard program for palm. This .jar is the desktop editor for the flashcards. It's worked before on Linux ... but that was almost 2 years ago.)
    Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
    at java.util.Vector.firstElement(Vector.java:442)
    at org.ekimd.twinkedit.TwinkUI.getJapFont(TwinkUI.java:979)
    at org.ekimd.twinkedit.TwinkUI$DynamicView.<init>(TwinkUI.java:589)
    at org.ekimd.twinkedit.TwinkUI.getDynamicView(TwinkUI.java:815)
    at org.ekimd.twinkedit.TwinkUI.access$1300(TwinkUI.java:88)
    at org.ekimd.twinkedit.TwinkUI$NewAction.actionPerformed(TwinkUI.java:1101)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6041)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
    at java.awt.Component.processEvent(Component.java:5806)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4413)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4243)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2440)
    at java.awt.Component.dispatchEvent(Component.java:4243)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    It happens in both 32 bit (arch32 chroot) and 64 bit jre's exactly the same.
    java -version gives:
    java version "1.6.0_07"
    Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
    Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)
    (It also doesn't work on Windows, either .... I think it must be a Java version compatibility problem ??)
    Any ideas?
    Thanks, 
    Scott
    Last edited by firecat53 (2008-09-27 14:07:04)

    I gave it a try and got the same error. Then I started looking at the code:
    When you create a new file, the program starts looking for a font which supports japanes (don't ask me why). If it doesn't find any it throws the error you posted above. I was able to create a new file after I installed ttf-bitstream-cyberbit from AUR (first font supporting japanese I could find).
    You should contact the author and submit a bug report. Even if the program really needs japanese fonts, which I doubt, failing like this is just bad.
    Last edited by Garns (2008-09-27 13:26:05)

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

  • 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

  • Problems with creation of JAR file

    Hi!
    I can't succeed in creating a JAR file for my application.
    I've followed the guide at http://java.sun.com/docs/books/tutorial/deployment/jar/basicsindex.html
    but apparently im doing something wrong....
    I've tried doing an extra Manifest file aswell as "Setting an Entry Point with the JAR Tool" as written in the guide. noen with success however :(
    I always get the error "Could not find the main class. Program will exit." from the JVM when I try to run my JAR file.
    Structure of my program:
    C:\searchpath\moresearchpath\projectname\src\
    inside src\ there are 3 packages called; "graphic", "client" and "server".
    I want to make a JAR file from the files in the "server" package. The "server" package consists of these following 4 files(and nothing more); "ClientHandler.java", "TestServer.java", "ServerModel.java", "ServerController.java".
    "TestServer.java" is my main class!
    This is an example of a command I've done in order to try to make a JAR file:
    "C:\searchPathToWhereJavaIsInstalled\jdk1.6.0\bin\jar cvfe sgwserver.jar server.TestServer server\*"
    This doesn't generate any error. However when I try to start the .jar I get following message "Could not find the main class. Program will exit."
    I've also tried creating manifest file manually but without success (with UTF-8 encoding and not double .txt ending on file)
    This is how the "Manifest.txt" file has looked when I've tried making one:
    Main-Class: server.TestServer
    I have used Netbeans 5.5 and Java SE 6 for development
    What am I doing wrong? Please help me :(

    If I try to run the one generated from Netbeans I get the following error message: "Failed to load Main-Class manifest attribute from C:\searchpath\moresearchPath\projectName\dist\projectName.jar"
    The thing is I need 2 JAR files, one that contains the files in the "server" package and one that has all other files. The other one is an applet and the files in "server" package are a standalone application.
    How do I get the standalone application's JAR file to work?

  • 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

  • Problems with jdbc and .jar files.

    I am having a problem with connecting to my database when running my .jar file as an executable.
    It connects correctly when I use the java command in command prompt and it also runs correctly when using my IDE.
    Is there something that needs to be added to the manifest or in the code it self inorder for the program to find the JDBC driver correctly?

    This is the error message that I get:
    java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at AboutFrame2$Connect.getConnection(AboutFrame2.java:109)
    at AboutFrame2$Connect.displayDbProperties(AboutFrame2.java:127)
    at AboutFrame2.<init>(AboutFrame2.java:72)
    at MainStartFile2.main(MainStartFile2.java:7)
    Error Trace in getConnection() : net.sourceforge.jtds.jdbc.Driver
    Error: No active Connection
    I think that it is because it cannot find the driver. I am going to add the path to the manifest and see if that works thank you for all the help.

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

  • Problem with using external jar file

    Hi
    I was using mail.jar library for swing application to send and receive emails. It just works perfect when I run with netbeans. But when I run the executable jar file at dist folder it runs but mail related functions doesn't work.What should I do now to make it work with mail features outside netbeans.
    thanks
    vinay
    Edited by: 899657 on Dec 24, 2011 5:07 AM

    899657 wrote:
    No. Because I am running the jar file which is created by netbeansNetbeans creates a 'dist' directory in which it puts your jar and a "dist/lib' directory in which it puts the dependent jars that are added to the project using 'project right mouse click'->Properties->Libraries. I would expect to see this 'dist/lib' directory contain mail.jar and activation.jar and any other jars that your jar needs. Within your program jar's manifest I would expect to see the Class-Path attribute have relative reference these jars ( lib/mail.jar lib/activation.jar ) and for the Main-Class attribute define your main class.
    Given this setup then you should be able to just type -
    java -jar yourjar.jarto run your program.

  • Why will my java.jar file not open

    Why will my java.jar file not open

    This is the iPod touch forum. Do you have a question concerning an iPod touch? The iPod touch does not run Java.
    If you have a new Mac you have to download the Java program to run Java on a Mac. It no longer comes with the iOS.

Maybe you are looking for

  • Unable to import the excel template into form in HFM

    Has any one came across this issue that I am facing now? I have a form in HFM and I exported the form to Excel and the export works fine. but when I import the excel template into form, it was not successful. I have 250 rows in the template. I delete

  • Safari on my macbook air keeps giving me  a safari quit unexpectedly and will not let me on the internet. Any ideas???

    I can not get on Safari. I see things like Exception type  EXC_BAD_ACCESS (SIGSEGV)   Thread creation by external task. The computer is less than 6 months ol and has nothing i cant live without. Can i do a factory reset or something similiar

  • Cannot be launched

    Please help me ... I'm getting this message Adobe acrobat 8.10 Professional cannot be launched at this time. you must launch at least one other suite compont(such as adobe photoshop)before launching acrobat 8.1.0 Professional. I did open Photoshop, b

  • TS4526 Unknown error when trying to play video from netflix or HBO go.

    When I try to play a video from Netflix or HBO go it attempts to load and says unknown error please try again later.  I've been trying this for several days.  I logged out then logged back in with no change.  It seems to play the other apps okay.  I'

  • Warp Stabilizer in CS6 does not work at all

    When using the CS6 Premiere Pro Warp stabilizer it starts to analyze but doesn't start to convert after it has finished analyzing. - Add the Warp Stabilizer - Blue bar over picture shows up "Analyzing in Background (Part1 of 2) - Prozess finishes but