[solved]can't run java apps from command line

Every Java program that i've tried to run from command line gives me a error message like this:
augusto java% java Test
Exception in thread "main" java.lang.NoClassDefFoundError: Test
Caused by: java.lang.ClassNotFoundException: Test
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Test. Program will exit.
`java Test.class` doesn't work too.
but, the exact same code work from eclipse, am I missing something?
Some info:
% ls Test*
Test.class Test.java Test.java~
% cat Test.java
public class Test{
public static void main(String[] args){
System.out.println("doesn't work");
% echo $PATH
/home/augusto/.bin:/home/augusto/.bin:/home/augusto/GNUstep/Tools:/opt/GNUstep/Local/Tools:/opt/GNUstep/System/Tools:/bin:/usr/bin:/sbin:/usr/sbin:/opt/java/bin:/opt/java/jre/bin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/opt/qt/bin
Last edited by hack.augusto (2009-10-27 00:57:53)

also make sure that you current directory is in your classpath.
eg
export CLASSPATH=".:$CLASSPATH"
java Test
your issue is more likely to be classpath related, as java doesn't read the path variable, and the java executable is found
Last edited by bruce (2009-10-27 01:02:51)

Similar Messages

  • How to run executable Java app from command line: No Main( ) method

    This is the opposite question from what most users ask. I have the Java source code and a running Java executable version of the program in a windows environment. I don't want to run it in the normal way by double-clicking on it or using the executable. I need to be able to run the same application from the command line. If I can do this, I can then compile and run the code on my Mac, too, which is what I am ultimately trying to accomplish.
    Normally, this would be easy. I would look for a Main method, normally public static void main (String[] args ) or some variation. I cannot find a main() anything, anywhere when searching the files. There must be some windows executable that links to the Java classes. It's very clever, no doubt, but that's not helping me.
    I am trying to run what I can determine as the Main class, with a standard command line call, but that is not working either.
    It is a Java graphics program, so mostly Swing container stuff.
    I am not finding a manifest.txt file, telling me where a main method is, nor anything about the Main Class. There is no readme file for the program.
    Any insight that would point me in the right direction? What should I be looking for?
    Thanks in advance, Bloozman

    It's possible there's a clever Windows executable that runs the class. But if it's a plain old Java class then there's a good chance there's a constructor. Look for that; it's possible you may be able to start by writing another Java class that creates an instance of your mystery class.
    When you have that done, try running it. It's possible that just creating an instance might be sufficient to run it. Swing programs are sometimes written like that. If not, then start looking for methods with names like "run" or "go" or "start" that your little controller program can call.

  • Running Oracle Scripts from Command Line

    Hi,
    How can i run Oracle scripts from command line.
    Actually i need to run these scripts from MSBuild before running Unit test projects

    C:\>sqlplus @myscript
    That would be the easiest variation
    C:\>sqlplus user/passwd@tns_alias @myscript
    would be an often used variation
    And then there is of course the version with parameter passing:
    C:\>sqlplus user/passwd@tns_alias @myscript param1 ... paramx
    Dunno about MSBuild

  • Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    The Mac OS X and iOS versions are separate products

  • Run test case from command line

    Hi  All,
    Working environment : VS 2013 professional 
    Project type : Unit test project for (Windows 8.1 and Windows phone 8.1)
    I have a set of unit test cases and want to run it on command line.I tried MSTest.ext and vstest.console.exe for running test case but not succeed.  
    command :  MSTest.exe /testcontainer:path of project dll
    command :  vstest.console.exe path of project dll
    Type of Error
    Error : Unit test case for windows store and windows phone app can't be run outside appcontainer. 
    Error : No tests to execute
    command :  MSTest.exe /testcontainer:path of appx
    command :  vstest.console.exe path of appx
    Error : root certificate error 
    I just want to run windows 8.1 and windows phone 8.1 run test cases from command line.
    Thanks in advance.

    Hi vicky2468,
    Based on your issue, as far as I know that if we want to run unit test for windows store and windows phone app using mstest.exe or vstest.console.exe in command line, you will need to execute the .appx instead of the dll in command line.
    In addition, I tried to run the appx for unit test in command line,
    but I found that I also get the same issue as yours. I could not execute the appx for unit test in command line successfully.  But if we run it with VS IDE in Test
    Explorer windows, it seems that it works fine.
    So I suggest you can submit a feedback for this issue, to get the issue confirmed and diagnose by product team, would you please create connect report for it? You will get email notification for update.
    http://connect.microsoft.com/VisualStudio/feedback/CreateFeedback.aspx
    When you submit the connect, I suggest you can provide your project for product team so that product team will
    be better help you solve this issue.
    If you submit it, please share me the link here, I will help you vote it. I think we could get the latest information
    from the product team experts. Of course, if I get any latest useful information, I will update it here.
    Thanks for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Running Unit Test from test manager that run bat file from command line

    Hi ,
    I am trying to run Jsystem (java framewotk) from command line using runScenario.bat thru unit test that i associated to test in test manager.
    the idea is that when i ran the automated test  from MTM - it will run the the unit test that will run the appropriate test case in java.
    i wrote the code like this : 
    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    namespace UnitTestProject3
    [TestClass]
    public class UnitTest1
    [TestMethod]
    public void TestMethod1()
    try
    String command = "c:\\JSYSTEM\\runner\\runScenario.bat
    c:\\Users\\ryeshua\\Source\\Workspaces\\Auto1\\my-tests-project\\target\\classes scenarios\\feature1 RoeySetup.xml ";
    System.Diagnostics.ProcessStartInfo procStartInfo =
    new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
    procStartInfo.RedirectStandardOutput = true;
    procStartInfo.UseShellExecute = false;
    //procStartInfo.CreateNoWindow = true;
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo = procStartInfo;
    proc.Start();
    string result = proc.StandardOutput.ReadToEnd();
    Console.WriteLine(result);
    catch (Exception objException)
    // Log the exception
    and when i ran it from visual studio it worked perfect. and update  the Jsystem logs of the junit test in the jsystem/runner/log folder.
    but when i added it to associated test and ran it from MTM - it pass but it does not update  the logs in jsystem folder.
    the problem that i dont know what is not working. i cant see the output of it when i ran from mtm but can see when i ran from VS.
    i am using VS 2013 Pro with MTM 2013.
    please advice
    Roey

    Hi Roey,
    Thank you for posting in MSDN forum.
    Based on your issue, could you please tell me how you generate the log file under the jsystem folder?
    Generally, I know that when we run unit test from VS IDE, the file will be saved into the local machine. But when we run unit test from MTM, the unit test method will be run on the test agent machine, so the file will be saved into the test agent machine.
    Therefore, I suggest you could check if you did not see the updated logs file in jsystem folder on the test agent machine.
    In addition, I suggest you could try to copy this unit test project on this test agent machine and then run the unit test method using mstest.exe in command line and then check if you can update the logs file.
    https://msdn.microsoft.com/en-us/library/ms182489.aspx?f=255&MSPPError=-2147217396
    If you have any updated message about this issue, please tell me.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • To run a report from command line, when using jdbc-odbc bridge

    Hi,
    How to run a report from command line, when using jdbc-odbc bridge?
    Usually with tns, we do by "rwrun module=<> userid=<user>/<passwd>@tns".
    with odbc, we do by "rwrun module=<> userid=<user>/<passwd>@odbc:DSN"
    Please specify, what is command line arguments for jdbc-odbc bridge driver?
    Environment : Oracle 9i Report Builder on WinNT
    Database : Sybase
    Regards,
    Ramanan

    Hello Ramanan,
    Report Builder : connect JDBC Query in Report Builder is to through Connection Dialog in JDBC Query Editor. User can use a Sign on parameter (can use, default : P_JDBCPDS or can create new) to connect to JDBC Data Source. Connection once made will be mentioned and will be reused through out Reports Builder.
    JDBC PDS allows user to connect one or more same or different kind of databases.
    While running report through runtime or Server, user can pass the sign on parameter(connection string) value, like any other user parameter.
    Syntax for connection string : <username>/<password>@databaseURL . The syntax of database part of connection string depend on the type of JDBC Driver used to connect to Data Source while designing the JDBC Query. databaseURL refer to the location of the database and its format depend on the JDBCPDS river selected in design time while creating the JDBC Query.
    rwrun eg :
    rwrun report=jdbc_odbc.rdf destype=file desname=output.html desformat=html P_JDBCPDS=scott/tiger@database
    Server eg :
    http://server.com:8888/servlet/RWServlet?server=MyReportServer+report=jdbc_odbc.rdf+destype=cache+desformat=html+P_JDBCPDS=scott/tiger@database
    http :
    Please see ORACLE_HOME/reports/conf/jdbcpds.conf for more information.
    With Regards
    Reports Team

  • How to run an executable from command-line

    I'm learning how to use the Terminal and I got stuck in a silly thing (I suppose it is). How can I run an executable file from command-line in Terminal?
    For example: I have a file named "Hello" in the folder /sample. If I use the ls command (ls sample), I can see the file Hello. Then I move to the directory (cd /sample) and try to run the file Hello (typing "Hello") but I got "command not found" message.
    If I drag the Hello file from Finder to Terminal and hit Return, it runs perfectly. And if I type the full path to the file (even if I'm already inside its directory), it also runs.
    So, my doubt is if there is any command to run an executable from command-line.
    Thanks

    KJK555 wrote:
    Hi VK:
    Can you enlighten me on why it's neccessary to do the "./" thingy in OS X when in unix/linux
    I never had to resort to doing that?
    Kj
    I took the trouble of reading *man bash* and it explains the issue. to add the current directory to PATH you need to add an empty path to PATH like this
    PATH=$PATH::
    you can add it to ~/.bash_profile so that it's executed automatically when you start bash. I suspect the linux system you are talking about had this set up by default or had it added to PATH in /etc/profile which defines PATH globally.

  • How to run Endeca Graphs from command Line

    Hi,
    I would like to know if there is any way to run Endeca Graphs from command line in Windows.
    Thank you,

    The correct way to execute a graph using the command line in windows is.......
    Execute the following command from the project folder:
    C:\Oracle\Endeca\Discovery\3.1.0\IntegratorETL\configuration\org.eclipse.osgi\bundles\5\1\.cp\lib\bin\clover.bat -plugins "/C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/configuration/org.eclipse.osgi/bundles/5/1/.cp/lib/plugins;/C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/configuration/org.eclipse.osgi/bundles/6/1/.cp/lib/plugins/;/C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/configuration/org.eclipse.osgi/bundles/9/1/.cp/lib/plugins/;/C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/configuration/org.eclipse.osgi/bundles/14/1/.cp/lib/plugins/;C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/configuration/org.eclipse.osgi/bundles/21/1/.cp/lib/plugins/;/C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/configuration/org.eclipse.osgi/bundles/23/1/.cp/lib/plugins/;/C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/plugins/com.endeca.latitude_1.0.0/lib/plugins/;/C:/Oracle/Endeca/Discovery/3.1.0/IntegratorETL/configuration/org.eclipse.osgi/bundles/358/1/.cp/lib/plugins/" -noJMX graph\graph_name.grf
    Our costumer needed to run some ETL process from ODI and once it finished start a Clover ETL process (automatically). So we created a .bat file witth the above command and then in ODI we created a package with all ETL interfaces and the last step of the package was a OScommand component that excecuted the .bat script from the Endeca's project folder.
    Hope you find this post helpfully.

  • Running FlexUnit tests from command line

    Sorry if that has been posted before: I searched best I could and nothing came up.
    I am interested in building and running my unit tests from the command line so we can add it to a nightly build process.
    I am *very* new to all this: basically I picked up Adobe Flash Builder 4 a month ago and I have done *everything* inside that IDE: writing code, building, testing, running.
    I looked into at least how to build something from the command line, I found this:
    http://help.adobe.com/en_US/flashbuilder/using/WSbde04e3d3e6474c4-59108b2e1215eb9d5e4-8000 .html
    Can't get past this error:
    Buildfile: /Users/dbanks/build_test.xml
    BUILD FAILED
    Target "FlexUnitApplication" does not exist in the project "null".
    Total time: 0 seconds
    Adobe Flash Builder 4:
    An error has occurred. See the log file
    /Users/dbanks/Documents/Adobe Flash Builder 4/.metadata/.log.
    Plus, even if I got this going, I am just building the swf.  I also want to run it and capture the output in some meaningful way that can be read/evaluated/acted on.
    FWIW, the script/xml I am using to try to build:
    build_test.xml:
    <?xml version="1.0"?>
    <project default="main">
        <target name="main">
            <fb.exportReleaseBuild project="NightclubMogul" />
        </target>
    </project>
    execute_build_test.sh:
    WORKSPACE="$HOME/Documents/AdobeFlashBuilder4"
    # works with either FlashBuilder.app or Eclipse.app
    "/Applications/AdobeFlashBuilder4" \
        --launcher.suppressErrors   \
        -noSplash   \
        -application org.eclipse.ant.core.antRunner   \
        -data "$WORKSPACE"    \
        -file "/Users/dbanks/build_test.xml" FlexUnitApplication
    I am not clear what in here is actually supposed to point to where my project lives: it's off in some directory somewhere.  I see that I am pointing to a workspace (Documents/AdobeFlashBuilder4) but when I poke around in there I don't see anything connecting back to the directories where the code lives.
    Any help would be great: getting the tests to build from command line, then getting them to run.

    C:\>sqlplus @myscript
    That would be the easiest variation
    C:\>sqlplus user/passwd@tns_alias @myscript
    would be an often used variation
    And then there is of course the version with parameter passing:
    C:\>sqlplus user/passwd@tns_alias @myscript param1 ... paramx
    Dunno about MSBuild

  • I can not uninstall Office 2013 from command line

    Hi, I have been stuck for a while trying to uninstall Office 2013 via command line. Installation file was downloaded from Volume Licensing Service Center, Uninstall.xml file for silent uninstallation looks like this:
    <Configuration Product=”ProPlus”>
    <Display Level=”basic” CompletionNotice=”yes” SuppressModal=”yes” AcceptEula=”yes” />
    </Configuration>
    From command line the following will not work:
    setup /uninstall ProPlus /config .\ProPlus.ww\Uninstall.xml
    Error: Setup can not find or validate an installation file. Please try reinstalling Office . . .
    setup /uninstall ProPlus gives me GUI to continue process - it seems /config .\ProPlus.ww\Uninstall.xml part does not work as it should be
    This is very important to me since I used above command line in SCCM 2012 R2 to allow user to uninstall Office 2013 by itself via Software Center. When this failed I tried locally but the error was the same. This should have been trivial task - silent uninstallation
    using .xml file. It is not a rocket science. I am very angry because losing time for something like this is unacceptable for system engineers working with SCCM 2012 R2.

    Hi,
    This error might occurs due to lots of reasons. Where is the installation file stored? If it's stored on a network share, please copy it to your local disk, and then manually run the command again. This way, we'll see if the installation file is the
    problem.
    If issue persists in this case, then this generally means that something wrong with the installation file. Please try to redownload it and then try again.
    Please also make sure that you're executing the command with elevated privileges (run as administrator).
    Regards,
    Ethan Hua
    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

  • How can I run my program on command line?

    I'm having some trouble trying to run my program on command line.
    I get a message saying "Exception in thread
    "main" java.lang.NoClassDefFoundError: Rectangle
    <a href="http://img145.imageshack.us/my.php?image=untitled2copylh2.jpg" target="_blank"><img src="http://img145.imageshack.us/img145/3002/untitled2copylh2.th.jpg" border="0" alt="Free Image Hosting at www.ImageShack.us" /></a>
    import java.util.Scanner;
    public class Rectangle
    public static void main(String[] args)
    int width;
    int height;
    int count = 1;
    Scanner scan = new Scanner (System.in);
    System.out.println("Please enter the width of the rectangle: ");
    width = scan.nextInt();
    System.out.println("Please enter the height of the rectangle: ");
    height = scan.nextInt();
    while (count <= width)
    if(width < 1 || width > 30)
    throw new IllegalArgumentException("The numbers must be in range");
    if(height < 1 || height > 30)
    throw new IllegalArgumentException("The numbers must be in range");
    for (int star = 1; star <= height; star++)
    System.out.print("*");
    System.out.println();
    count++;
    }

    What doesn't work?
    When you type javac Rectangle.java do you get error messages? Does it create the file Rectangle.class? If yes, type java Rectangle and your program should run. If you get an error post it but if you followed earlier advice you should be able to solve the problem yourself.

  • Can't Run Java Apps

    I use Java run live stock market feeds which have always worked perfectly on 10.4.10. Just bought a new MacBook running 10.5.1 - I managed to get it working a couple of times but now will not work at all. I tried everything I can think of including fsck which found no faults and I even copied over my Java files from my PowerBook to the MacBook. So it seems that 10.5.1 does not work with Java J2SE 5.0. The application I run says I need Java 1.5 but I cannot seem to locate this anywhere to download and the previous versions in the J2SE 5.0 are 1.3.1 and 1.4.2 plugins. The site where I am logging into the live fees from does have link to a 1.5 plugin which I have downloaded several times but makes no difference, when I open the file it is all weird looking text which may be perfectly normal, not sure e.g.
    MZê

    It is run as a desktop app, and other runs with commands such as JOptionPane do function, only the println windows don't appear at all. So I think JRE is installed and working.
    I did notice there was one command for input where I'd be able to enter it at the bottom of Netbeans.
    Like just now I clicked build and run for the following code
    import java.util.*;
    public class FirstProgram
        public static void main(String[] args)
            System.out.println("Hello out there.");
            System.out.println("I will add two numbers for you.");
            System.out.println("Enter two whole numbers on a line:");
            int n1, n2;
            Scanner keyboard = new Scanner(System.in);
            n1=keyboard.nextInt();
            n2=keyboard.nextInt();
            System.out.println("The sum of those two numbers is");
            System.out.println(n1+n2)
    }Resulting in a brief flash of "input" in the output window (which is below the coding window) and it dissapears. But this also occurs when I don't include system scanner code.
    Using commands in cmd
    java -jar "C:\Users\Alegis\Netb\MyApp\dist\MyApp.jar"
    Does not yield desired results either. Nothing happens.

  • Can we run java bean from forms client server??

    Hi,
    The OLTP application we are planning to build has lot of gui e.g
    tabs, drag and drop etc. Our aim is to make it web enabled but
    the network bandwidth available is small 16 - 64K . So even
    thoughwe plan toi use applet , we seriuosly doubt how good it
    will perform on such low network bandwidth. [The system will
    have 100 users]
    Q1. What will be a reasonable bandwidth to run an oltp
    application (say maintenance )
    Hence we are thinking of developing with developer 6i and
    deploying our application in client server mode, which can
    easily be web enabled in future. But we also have to integrate
    visual interfaces like gantt chart, which are not available with
    forms. We plan to use third party java component (e.g ILOG
    jviews), so that in future we can easily web enable the entire
    application.
    Q2. Can we run forms with java bean in client server mode? If
    not, what are the products to be installed on each machine to
    run it without using 9ias?
    best regards

    Yes. We can run sql loader from client machine.
    C:\Karthik>sqlldr user/pass@database data='test.csv' control='test.ctl' log='test.log' bad='test.bad'
    You can go through the following link for better understanding.
    http://www.oreilly.com/catalog/orsqlloader/chapter/ch01.html

  • ID CS5 on Mac 10.5.8 can't run java scripts from User folder

    I seem to have a problem with my java scripts in ID on my Mac. I store them in my user scripts folder, but while I can run any applescripts in the folder, doubleclicking on any of the java scripts gets me exactly nothing. If I open the scripts in Extend Script Toolkit and run them from there, they will work, but I can't run them from within ID. The scripts in the Sample Script folder work. I've tried changing the script extentions, I've opened them in the toolkit and resaved them. Still no response at all when I doubleclick on them in the scripts panel. Any idea what could be wrong? I can run the same scripts from within ID on my Windows laptop, so I don't think the scripts themselves are at fault. In fact, I just moved them into the Sample scripts folder, and they run with no problem. Does the User script folder just not work?

    Not sure what a screenshot will tell you, but here you go.
    Well, I was hoping that the icon next to the scripts would be instructive.
    Apparently not, though!
    You said the same scripts work fine if you move them into the Application Scripts folder, specifically the Sample Scripts folder. I assume, then, that the sample scripts also break if moved to the User Scripts folder?
    Is your User Scripts folder (and thus your home directory) on a non-local (network) filesystem? Are the permissions on it wacky? If you Reveal In Finder it, and Get Info, do you see anything out of the ordinary?
    What if you delete it (err, move it aside) and recreate it?
    This seems pretty strange...

Maybe you are looking for