Running a jar from the command line

I am trying to run a Jar from the command line. I have a number of classes in a package called "trainnn".
I put all the classes into a jar
jar cvf name.jar trainnn\*.classI then creat a file called mainClass.txt with the line (with a blank return line after it, where QueryMatch has the main). This file was placed in the same directory as the package and the jar file
Main-Class: QueryMatch
then
jar cmf mainClass.txt network.jar G:/TrainNN/src/trainnn/QueryMatch.classthis worked fine.....but it is from here I have problems when I try run the jar
java -jar network.jarbut get this error.
Exception in thread "main" java.lang.NoClassDefFoundError: QueryMatch
I cant figure out this error, I have tried specifying the exact path in the mainClass.txt file but that didnt work.
Any ideas
Thanks in advance.

Hi,
To start a java app in the command line with "java -jar yourJarFile.jar", the jar needs to have a mainfest file "MANIFEST.MF" in a folder called "META-INF". The manifest file would have to contain the name of your starting class, e.g. it could look like thisManifest-Version: 1.0
Main-Class: com.yourCompany.yourProject.YourClass Hope that helps. Cheers, HJK

Similar Messages

  • Running powewrpc programs from the command line

    I am trying to run a powerpc application (quicken) from the command line. I want to log into the mac over my local network and run a powerpc program, but I get the following when I try it:
    cannot execute binary file
    I am logging in via ssh, and am running the X11 package from a different unix system which also runs X11.
    How do I get the application to execute? (it runs fine from the desktop).

    I am sitting at a Sun Solaris machine (it runs X11R6
    and Matif). I want to run Quicken, which is on the
    mac mini. I log into the mac with ssh -X. I find the
    Quicken program, but the permissions are set to 644
    (read, but not execute). If I change the permissions
    and try to run the program I get teh error message
    "cannot execute binary file".
    The window interface of the Mac is not X11: so you cannot output it on another X system. Is is not like connecting to another Un*x system.
    Said that, you should be able to launch a program, but you cannot see the output. However, usually Macosx applications are bundles with some executable inside, not directly an executable file: .app files are folders, not files. In order to launch such kind of apps, you have to use the open command I suggested in the previous post.
    I have no idea what VNC is. If this is how I can do
    this, then please provide me a link to it.
    VNC is a screen sharing application, just like Windows Remote Desktop. You may install a VNC server on your mac mini, and then connecting with a VNC client you will see all your computer screen as if you were there. It is cross platform, so no matter which is your client (including mobile phones).

  • Problem with running a java program from the command line

    I have this code:
    package pkg;
    import jxl.*;
    import java.io.File;
    public class TestClass {
         public static void main(String[] args) {
              try{
                   Workbook book = Workbook.getWorkbook(new File("d:/testWorkspace/excFile.xls"));
                   Sheet sheet = book.getSheet(0);
                   String s=sheet.getCell(4, 2).getContents();
                   System.out.println(s);     
              }catch (Exception e){System.err.println(e);}
    }I've wrote it in Eclipse, added jxl.jar to the buildpath, and it works fine.
    Then I tried to run it from the command line and I did it like this:
    D:\testWorkspace\testProject\bin> java -cp \jxl.jar pkg.TestClassThe result was:
    Exception in thread "main" java.lang.NoClassDefFoundError: pkg/TestClass
    Caused by: java.lang.ClassNotFoundException: pkg.TestClass
    ...but the file TestClass.class DOES exist in the folder d:\testWorkspace\testProject\bin\pkg\ and the file jxl.jar IS on the root of drive D (like I already wrote, it worked fine inside the Eclipse).
    So, my question is: How to run this code from the command line?
    I have no idea what went wrong.
    Can someone help me, please?

    The current directory is not implied in the classpath.
    D:\testWorkspace\testProject\bin> java -cp .;d:\ pkg.TestClassor
    D:\testWorkspace\testProject\bin> java -cp .;d:\jxl.jar pkg.TestClassI always forget which is right since I never work with jars...

  • I am unable to run several iMacros from the commnd line concurrently

    The documentation implies that you can run concurrent iMacros by starting Firefox sessions under different profiles. I have tried this, but if I run Firefox from the command line it only takes note of the -P (profile) option if I am also specifying -no-remote (start in a new process). the problem is that to run an iMacro from the command line you have to start a firefox session first, then wait briefly before making the actual firefox call to your iMacro. So I can start a number of separate Firefox sessions under different profiles OK, but when I try to call my iMacros they might go to any of the sessions, and they just end up all hanging.
    If I start my Firefox sessions then go into them manually, I can start the iMacros one iMacro in each and they run fine concurrently.

    Are these newly purchased films or films purchased in the past that you want to re-download ? The 'check for available downloads' will check for things such as pre-orders that haven't been downloaded yet, and (I think) automatic downloads - it doesn't check for things which you've downloaded in the past but which are no longer in your library. If they are past purchases, then depending upon what country that you are in (films can't be re-downloaded in all countries), and whether they are still in the store (film studios occasionally remove them) then they might show under the Purchased link under Quicklinks on the right-hand side of the iTunes store home page on your computer's iTunes for re-downloading.

  • Jar file runs from the command line, but not when I double click it

    Hello, I'm running windows xp. I've created an executable jar file and it runs fine from the command line when I type;
    java -jar wizard.jar
    but, when I double click it . . . nothing.
    Any ideas?

    nothing ? that's weird, windows XP should prompt you to select the program you want to use in order to open Jar files (and give you this silly piece of advice to search the web for the appropriate program)
    you might want to check what program (if any) got associated with .jar extensions :
    in Windows Explorer : Tools => Folder Options => File Types
    hth

  • Help required - running a Java program from the command line

    Hi,
    I have a small non-graphical Java application, packaged into a Jar file. My program relies on classes in another (external) Jar file.
    When I run the application from the IDE, everything works fine. However, when I try to run the application from the command line, I keep getting a NoClassDefFoundError for classes in the external jar.
    Both the application jar file and the external jar file are in my root directory (C:\).
    My command line call is as follows:
    java -cp c:MyExternalLib.jar -jar MyApp.jar
    Any help greatly appreciated.
    Thanks,
    Walter

    hi,
    set classpath=%classpath%;c:\myjar.jar;
    here i have specified myjar.jar file as an example u give ur location.after setting the classpath run ur java application.
    java mypgm
    this will solve ur problem
    regards,
    Ganesh

  • Run javascript (not in a jsx file) from the command line extendscript

    Hi all,
    I was wondering if anyone knew how to run javascript from the command line in Extendscript (meaning Extendscript would be the target application). I know about the -run command line flag in which allows you to run a .jsx script from the command line but what I'm looking for similar syntax to run a script directly without needing to put it in a file. For example I have tried (obviously unsuccessfully):
    C:\Program Files (x86)\Adobe\Adobe ExtendScript Toolkit CC\ExtendScript Toolkit.exe -run "alert('Hello World');"
    Thanks!

    You might be looking for something like this: javascript - Is it possible to execute JSX scripts from outside ExtendScript? - Stack Overflow
    Although that one is about executing JSX files, the solutions given (Applescript as well as COM/VBScript) can be adapted to simply run a javascript code snippet rather than JSX file because the solutions simply call the Adobe app's Applescript/COM API to "execute javascript" (actually execute ExtendScript technically), and in the solution, they using includes to pull in the JSX file. You'd simply replace the include with actual javascript code snippet inserted in.
    Though this would then require you to run a VBScript, Applescript, or other script (that calls the COM/Applescript API) rather than the ESTK command line option.

  • Is it possible to run Acrobat3D from the command line?

    I'd like to know if it is possible to run Arobat3D from the command line in batch mode. I'm interested in knowing if this is possible in either a windows or unix environment.
    My objective is to convert CAD data e.g. CATIA V5 or DXF etc to PDF, in batch mode without using the Acrobat3D interface itself.
    I know that it's possible to run a batch process from within Acrobat3D itself, therefore one solution may be to invoke those batch processes from the command line.
    I've looked through the other listings on this forum and seen this question asked previously, but I've not seen any responses that suggest this is even a feasible concept.

    As of now, it's not possible in the cmd-mode to just remain connected and not stream.
    But the reason you want to do that is because of the long start-up time. That 20 sec time can be divided into:
    1. launch time
    2. time to start encoding (after pressing start button) -> cannot be reduced even if 'connected only' feature is available in cmd-line
    Below are tips you can use to reduce this 20 sec of time:
    1. Lesser the no. of devices connected to the system, shorter is the launch time. Disable the devices which are not to be used in the session.
    2. Try using device indexes (0, 1, 2, etc) instead of device names in the profile. Indexes might change after you disable some of the devices.
    3. Use the profile with correct settings, to avoid any validation errors.
    4. Higher the video size, higher is the overall time. Small sizes take lesser time to start.
    Let me know if you see any improvement in the startup time.

  • Running a function from a powershell script from the command line

    Rather than creating several scripts each with one function, I have one script with has several functions.... I would like to call the script and select the function i want to use from the command line.
    so far, if i change directory to that of the script i can call the function by doing this:
    cd c:\myscripts
    . .\mytestscript.ps1; myfunction
    this works fine.... i have also tried, what I would like to achieve is calling it like this
    c:\myscripts\mytestscript.ps1; myfunction
    however, i am trying to run this as part of an MDT task sequence, my command line looks like this and using the ; myfunction at the end doesn't work.
    powershell.exe -ExecutionPolicy Bypass %SCRIPTROOT%\CustomScripts\mytestscript.ps1; myfunction
    how can i adapt my command line so that it will successfully call the function within my script?
    thanks
    Steve

    Rename the file from ps1 to psm1 and create a powershell module that contain multiple functions. A module will autoload like the built-in modules.
    Placement of the psm1 file is important for Powershell to find and autoload it.
    The file name and folder name must be the same, for example MyModule.psm1 should be in the folder:
    user\documents\windowspowershell\modules\mymodule
    Windows PowerShell Modules
    http://msdn.microsoft.com/en-us/library/dd878324(v=vs.85).aspx
    PS C:\> get-childItem env:PSModulePath
    Name Value
    PSModulePath C:\Users\User\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

  • I used to beable to push firefox with sccm using setup.exe from the command line , this no longer works i want to be able to have a silent install run for all,

    In the past I have always created a deployment with sccm and installed firefox.exe with the /s switch from the command line what is the new switch for silent installation ?

    hello, have you tried it with the full installers that are available at https://www.mozilla.org/firefox/all yet?

  • Is there a way to switch between workspaces in Spaces from the command line?  I want to write a script to set up certain applications in certain workspaces (without having to do it manually each time)...

    Is there a way to switch between workspaces in Spaces from the comnand line?  I use several workspaces from Spaces, each workspace having a certain number of fixed applications running.  Rather than set all this up each time I log on, I'd like to write a script from the command line (I use gawk) to automate this. Currently I have a gawk script that, given a directory, opens a few xterms whose working directory is the given directory, and opens "preview" applied to a certain file in that directory.  However, at present I have to manually move an xterm through each workspace and run my gawk script in each workspace (applied to each directory that I'm working on).
    There must be a better way...

    Addendum: Can this be done via:   open -a Spaces --args xxx  , where xxx is some set of arguments (or something like this)?

  • Get the absolute path and filename of the file from the command line

    Hi,
    when we run the class we give the command
    java <filename>
    How can I capture the filename given above and get its absolute path inside the
    public static void main(String [] args){}
    args[0] gives me the command line argument after the filename. How do I capture the filename itself from the command line argument and also get that files absolute path
    Thanks

    I don't know of any way to capture the java command input, but there are ways to find out where the application is being run from. (the "absolute path")
    http://forum.java.sun.com/thread.jsp?forum=31&thread=335394

  • Problem - reading an abitrary string from the command line in basic swing

    Hi,
    I'm sorry if this problem is a bit basic, but I've only just started swing in Java. Anyway, I'm trying to adapt a basic swing version of the HelloWorld class. When I try to pass an abitrary string from the command line to the label within the class, I get the following error,
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
            at week2.HelloWorldSwing_commandline.main(HelloWorldSwing_commandline.java:31)
    Java Result: 1I must be missing something because I can't see where the problem is in the following code.
    import javax.swing.*;
    import java.awt.*;
    public class HelloWorldSwing_commandline {
        String message;
        private static void createAndShowGui(String message){
            JFrame.setDefaultLookAndFeelDecorated(true);
            JFrame frame = new JFrame("HelloWorldSwing");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JLabel label = new JLabel(message);
            Container content = frame.getContentPane();
            content.add(label);
            frame.pack();
            frame.setVisible(true);
        public static void main(String[ ] args) {
         createAndShowGui(args[1]);
    }Any help would really be appreciated.

    Hi,
    I've tried changing the index value to O in the main method, but I still get the same error.
    I'm running this in NetBeans 4.1, and when I try to run the class I get the error as listed above.
    Any ideas how to correct this error?
    Thanks

  • Get GPS location from the command line

    Is there a utility to get the current GPS location from the command line?  A quick search says `geo` will do it, but that appears to come with the android dev tools, which I'd rather not install right now.  The reason I want to do this is to avoid hard-coding my coordinates in a call to `redshift`.

    enduser wrote:
    Hmm.. `gpspipe` gives me:
    gpspipe: could not connect to gpsd localhost:2947, Unknown error -6(-6)
    And `gpsd` gives me:
    gpsd:ERROR: can't run with neither control socket nor devices
    Do I need to be root for these applications? Alternatively, could I maybe just grab the timezone from /etc/localtime and use that? (though I guess that doesn't get close enough on longitude...)
    You have to start gpsd from systemctl.  And you can plug/unplug gps devices at will, so it can be enabled in systemctl whether or not an actual gps is always available.

  • How to create an alias from the command line

    Hi
    I would like to know how to create an alias (for a file, not a command) from the command line. I don't want to use the ln command, as an alias has more interesting features than soft/hard links... Is there an Apple specific tool to do this?
    Thanks
    -Jerome
      Mac OS X (10.4.10)  

    The only straightforward way that I am aware of for creating a "Finder" alias from the command line is using AppleScript via 'osascript'. Of course, it's not really a command line solution since the "Finder" has to be running. Anyway, something along the lines of:
    <pre style="overflow:auto; padding: 5px; width: 500px ; font-size: 10px; border:1">osascript -e 'tell application "Finder" to make alias file to POSIX file "/full/path/to/file" at POSIX file "/full/path/to/folder"'</pre>

Maybe you are looking for

  • HT4623 How can I get Imessage back on my phone

    How can I get Imessage back on my phone

  • Creating XML format

    Hi  All, Can anyone please explain what is the difference between creating an XML format from an internal table using  CALL TRANSFORMATION and using CLASS BUILDER? In  class builder  we have  to Create the main iXML factory , then Create a stream fac

  • Google Mail Storage

    I have two google accounts setup on my phone. When I delete an email from my phone it deletes it from my inbox through Gmail.  Do the emails get stored on the phone? I keep deleting all my emails off my phone because I thought they were taking space,

  • Bugs in the latest ThinkVantage Productivity Center update

    Hi, last Friday I updated the Thinkvantage software on my T61 (WinXP). Beside fixing some problems it brought me new ones. Foremost, now, as soon as I set my machine into the Lenovo Portreplicator (docking station), it simply goes POWER OFF. No messa

  • I just purchased and downloaded a book but can not play it.

    I am using iTunes 10 on an imac. Under purchased items it is listed as a protected book. But it subtracted the dollars from my account. What is up?