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

Similar Messages

  • 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

  • How to run a Java program without the command line.

    Is there anyway to create a Java program that runs like most programs do in Windows ,by double clicking on their icons?
    Thanks,
    Vance

    http://www.ej-technologies.com/products/exe4j/overview.html
    Looks kinda cool. Most java-2-exe programs are usually way too expensive and wont work with GUIs and require other dlls/libraries...

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

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

  • How to run the Quick Repair in Uninstall a Program from the command line

    Hello everyone.  Right now we're manually going onto machines and opening Control Panel, Uninstall a Program, then doing a Change on our Office 365 2013 installs to run the Quick Repair option.  Is there a better way to do this with a command line
    command (that only references local files on the machines), or just issues the same exact command that our manual intervention described above does? 
    We have the click to run version installed also if that matters.

    Hi,
    To run a Quick Repair for 64-bit operating systems:
    “C:\program files\Microsoft Office 15\ClientX64\integratedoffice.exe” RUNMODE RERUNMODE modetorun repair
    To run a Quick Repair for 32-bit operating systems:
    “C:\program files\Microsoft Office 15\ClientX86\integratedoffice.exe” RUNMODE RERUNMODE modetorun repair
    Note: The above commands need to be run from an elevated command prompt.
    For more information, please refer:
    http://blogs.technet.com/b/office_resource_kit/archive/2013/06/17/automating-quick-repairs-in-office-365-proplus.aspx
    Hope this helps.
    Regards,
    Steve Fan
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

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

  • URGENT: How to run a Java program from a different directory?

    Hi.
    How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
    What would be the command to run the Java file from c:\Java.
    I can't remember it and I need it asap.
    Cheers.

    If the class you are trying to run is MyApp.class, try
    c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
    Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
    The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)".

  • How to run a Concurrent Program from the back end?

    Hi,
    How to run a Concurrent Program from the back end?
    Is it Possible to see that Concuurent Request id which we run from the back end, in the front end?
    If yes, then Please Give reply how to write the code
    Thanks in Advance,
    Bharathi.S

    This is documented in Chapter 20 of the Application Developers Guide http://download.oracle.com/docs/cd/B53825_03/current/acrobat/121devg.pdf. These MOS Docs also have some information available
    221542.1 - Sample Code for FND_SUBMIT and FND_REQUEST API's
    235359.1 - How to Launch Planning Data Pull MSCPDP using FND_REQUEST.SUBMIT_REQUEST
    HTH
    Srini

  • Testing Java Concurrent Program on the command line in Windows

    I'm using the suggestions in:
    http://blogs.oracle.com/xmlpublisher/2007/05/02
    to test my Java concurrent program on the command line. Our production environment is running on Unix. I've been able to test it successfully on the Unix environment from the command line. However, it fails when I try to test it on the Windows command line with the following stack trace:
    Exception in static block of jtf.cache.CacheManager. Stack trace is: oracle.apps
    .jtf.base.resources.FrameworkException: IAS Cache initialization failed
    at oracle.apps.jtf.cache.IASCacheProvider.init(IASCacheProvider.java:225
    at oracle.apps.jtf.cache.CacheManager.activateCache(CacheManager.java:14
    44)
    at oracle.apps.jtf.cache.CacheManager.initCache(CacheManager.java:752)
    at oracle.apps.jtf.cache.CacheManager.<clinit>(CacheManager.java:378)
    at oracle.apps.fnd.cache.Cache.setCacheFullName(Cache.java:228)
    at oracle.apps.fnd.cache.Cache.initCache(Cache.java:114)
    at oracle.apps.fnd.cache.Cache.<init>(Cache.java:89)
    at oracle.apps.fnd.cache.AppsCache.<init>(AppsCache.java:86)
    at oracle.apps.fnd.cache.AolCaches.getCache(AolCaches.java:155)
    at oracle.apps.fnd.profiles.Profiles.<clinit>(Profiles.java:241)
    at oracle.apps.fnd.profiles.ExtendedProfileStore.init(ExtendedProfileSto
    re.java:498)
    at oracle.apps.fnd.profiles.ExtendedProfileStore.<init>(ExtendedProfileS
    tore.java:119)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at oracle.apps.fnd.common.AppsContext.instantiateProfileStore(AppsContex
    t.java:4312)
    at oracle.apps.fnd.common.AppsContext.makeProfileStore(AppsContext.java:
    1171)
    at oracle.apps.fnd.common.Context.setProfileStore(Context.java:970)
    at oracle.apps.fnd.common.Context.setProfileStore(Context.java:952)
    at oracle.apps.fnd.common.AppsContext.initializeContext(AppsContext.java
    :958)
    at oracle.apps.fnd.common.AppsContext.initializeContext(AppsContext.java
    :918)
    at oracle.apps.fnd.common.AppsContext.<init>(AppsContext.java:752)
    at oracle.apps.fnd.cp.request.CpContext.<init>(CpContext.java:141)
    at oracle.apps.fnd.cp.request.CpContext.<init>(CpContext.java:124)
    at oracle.apps.fnd.cp.request.Run.main(Run.java:127)
    Caused by: oracle.apps.jtf.base.resources.FrameworkException: null
    null
    CacheDefaultConfig.properties (The system cannot find the file specified)
    at oracle.apps.jtf.base.resources.FrameworkException.convertException(Fr
    ameworkException.java:607)
    at oracle.apps.jtf.base.resources.FrameworkException.addException(Framew
    orkException.java:585)
    at oracle.apps.jtf.base.resources.FrameworkException.<init>(FrameworkExc
    eption.java:66)
    at oracle.apps.jtf.base.resources.FrameworkException.<init>(FrameworkExc
    eption.java:88)
    at oracle.apps.jtf.base.resources.FrameworkException.<init>(FrameworkExc
    eption.java:202)
    at oracle.apps.jtf.base.resources.FrameworkException.<init>(FrameworkExc
    eption.java:218)
    at oracle.apps.jtf.base.resources.FrameworkException.<init>(FrameworkExc
    eption.java:249)
    ... 26 more
    Exception in thread "main" oracle.adf.mds.exception.MDSRuntimeException: Cache n
    ot initialized
    at oracle.apps.fnd.framework.mds.cache.ATGCacheMgrDelegateImpl.<init>(AT
    GCacheMgrDelegateImpl.java:325)
    at oracle.apps.fnd.framework.mds.cache.ATGCacheFactoryImpl.<init>(ATGCac
    heFactoryImpl.java:44)
    at oracle.apps.fnd.cp.request.CpContext.getMDSContext(CpContext.java:116
    9)
    at oracle.apps.fnd.cp.request.Run.main(Run.java:130)
    I've put the appsborg2.zip file in my classpath. I've also copied the entire (1 GB) worth of Java .class files for Oracle apps onto my computer and placed it on my classpath. Is there something that prevents me from testing out my Java concurrent program on my Windows machine from the command line?

    i think if u run the ap in the command line then it has to stay open, you could try writing a .bat file then when that is executed it will only open the command line for the program execution (i think)

  • 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

  • Running jar files from the command line

    I have always felt it would be useful to run a jar file from th command line in EXACTLY the same way as an EXE. On some systems, typing MYAPP.JAR will run the app, but doesn't output and command line data, so it only works for GUI apps. I've come up with a tiny C program that runs java -jar xxxx.jar for you.
    #include <stdio.h>
    #include <string.h>
    #include <process.h>
    void main(int argc,char *argv[])
         char cmd[1024];
         strcpy(cmd,"java -jar ");
         strcat(cmd,argv[0]);
         strcat(cmd,".jar");
         for(int arg=1;arg<argc;arg++)
              strcat(cmd," ");
              strcat(cmd,argv[arg]);
         system(cmd);
    }Simply compile this to an exe, rename the exe to the name of your jar file and put it in the same directory. Then just type 'MyJarFile' (no jar extension) and it should run. It passes all command live args as well. Comments ?

    Here's a better version. The JAR and the EXE can be anywhere in the PATH:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <process.h>
    void main(int argc,char *argv[])
         char jar[1024];
         char cmd[1024];
         strcpy(cmd,argv[0]);
         strcat(cmd,".jar");
         _searchenv(cmd,"PATH",jar);
         strcpy(cmd,"java -jar ");
         strcat(cmd,jar);
         for(int arg=1;arg<argc;arg++)
              strcat(cmd," ");
              strcat(cmd,argv[arg]);
         system(cmd);
    }

  • 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

  • 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

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

Maybe you are looking for

  • Error while using the XMLP API to generate a report

    Hi all, I am trying to generate a report using stand-alone application by the JAVA API (User doc Ch 11). I am using RFT template for this. Step1: Create XSL from RTF file. I could do this. Example is given in page 262 of the guide. Here is the code s

  • Ploting new plot in xy graph on button click

    hi all experts i need your help. i want to plot multiple graph, on a single xy graph i want -->if user want to plot a new plot user will place new button,give value of parameter using control,do needed operation . then press button name as plot. on b

  • Cannot open links in new tab without holding Ctrl

    There is only one option i see in preferences for opening sites in new tabs. and it is called "Open links from applications..." Even with this checked, by default all links open in a new window, unless I hold down Ctrl while clicking the link. There

  • My apple tv says no signal on tv.i check all the connections but still says no signal

    apple tv not connecting to tv...i tried all the possible solutions but still tv says no signal

  • Constantly rebuilding Mail

    Here's the deal: I used Entourage for a long time but with my new MacBook I decided to give Mail a try. It's good, but I'm having a problem that I can't solve, so I'm thinking on going back to Entourage. I manage 4 POP accounts. The first one is my c