Using Java in windows command prompt

Hi,
I don't know if I have been searching correctly, but I haven't found a solution to my problem through common search engines.
I'm programming in java using vim (accessed through windows command prompt), and I've created classes, everything compiles fine.
However, I wanted to test my classes my creating instances of them (i.e. objects) through the same windows command line (command prompt). I know you can achieve this by using interaction panes through third party programs such as Dr.Java and eclipse, but I was wondering if this can be done using the command line.
Thanks
Jaime

Thanks Paulcw for your quick reply! :D
I'm guessing I didn't word my question properly.
Neither of my classes have a main method in them, so when I am trying to create instances (objects) of them, I would like to as if my command line was the main.
For example:
Class1 c = new Class1(parameters);
c.moveRight();
etc.
I'd like to be able to use my classes methods from the command line, I think what I'm looking for is a batch, but I'm not sure.
Thanks again,
Jaime

Similar Messages

  • Problem on Creating Unix Termial in java like windows command prompt

    hi all,
    i created an unix terminal using java swing(to connect unix server and executing commands). here i redirect the console output to textarea. The problem is i can't read the input from the textarea. and another problem is how to disable the editable option in the textarea before to the command read line. The terminal is like a putty. Any One Please give a suggestion for this problem.

    sabre150 wrote:
    georgemc wrote:
    LinaGsp wrote:
    5)then I run this command "jar cvfm MyJar.jar manifest.mf .class"If this is exactly what you did, and not a typo, that's probably your problem. Do you have a file called .class?It is more likely that the forum markup is getting in the way.Of course it is! D'oh! I seem to have a blind spot to that, I never take it into consideration...
    OP, listen to these guys, ignore this blind old fool :-(

  • Java Code Compilation in Windows Command Prompt

    Hi Everyone,
    I have been programming in java for quite some time now using an IDE (eclipse). I downloaded the following java file from:
    http://java.sun.com/javase/technologies/desktop/media/jmf/2.1.1/solutions/JpegImagesToMovie.html#requirements
    and have downloaded the required JMF. The problem is that I want to compile and run this code in Windows Command Prompt; however, I keep receiving errors upon compilation because I do not know how to make jmf.jar be recognized as a library.
    Thx.

    javac -cp jmf.jar;otherJars file1.java file2.java file3.java...
    Run java and javac from the command line for an explanation of their options.
    Edited by: nclow on Jul 24, 2008 1:43 PM

  • Manipulating Windows command prompt through Java

    I am wondering if there is any way to manipulate simple Windows command prompt commands like color, cd, dir, cls through a java application. Any help or informative redirection would be much appreciated.

    BinaryBurnout wrote:
    I am wondering if there is any way to manipulate simple Windows command prompt commands like color, cd, dir, cls through a java application. Any help or informative redirection would be much appreciated.Realize that the Windows command prompt is an application (cmd.exe), and those commands are specific to that application.

  • How to execute a scenario from Windows command prompt

    Hi,
    I have a package which is executing fine from Designer. But the same scenario if I am trying to execute from windows command prompt, then it is giving error.
    The package is getting a refresh variable, passing to interface which is creating a file from table, this file is then getting FTP'ed to another server.
    I am executing following command -
    startscen OB_TAB_TO_FILE_PKG 001 ODICTX "-v=2"
    The error is -
    A JDK is required to execute Web Services with OracleDI. You are currently using
    a JRE.
    OracleDI: Starting scenario OB_TAB_TO_FILE_PKG 001 in context ODICTX ...
    java.sql.SQLException: socket creation error
    at org.hsqldb.jdbc.jdbcUtil.sqlException(jdbcUtil.java:67)
    at org.hsqldb.jdbc.jdbcConnection.<init>(jdbcConnection.java:2451)
    at org.hsqldb.jdbcDriver.getConnection(jdbcDriver.java:188)
    at org.hsqldb.jdbcDriver.connect(jdbcDriver.java:166)
    at com.sunopsis.sql.SnpsConnection.u(SnpsConnection.java)
    at com.sunopsis.sql.SnpsConnection.c(SnpsConnection.java)
    at com.sunopsis.sql.i.run(i.java)
    DwgJv.main: Exit. Return code:-1
    Please let me know where I am going anything wrong.
    Thanks,
    Himanshu

    Hi,
    you need to make the necessary changes to the %odi%\bin\odiparams.bat config file, under the "Repository Connection Information" section so that startscen knows how to extract metadata from your repository.
    You apparently have left the default settings to the Hypersonic demo repository. Is that the technology your repository is hosted on?

  • Unable to connect to database from windows command prompt

    Hi All,
    Im trying to connect to Oracle database from my windows command prompt, these are the steps I followed:
    1) cd C:\oracle\product\11.2.0\client_1\sqlplus
    2) sqlplus username\password@hostname:1521\service_name
    I do get the error ORA-06401: NETCMN: invalid driver designator
    I did try using the SQLPLUS \NOLOG
    Connect username\password@hostname:1521\service_name
    I still get the same error.
    I did manually type all the commands to make sure no additional charaters coming and etc...How shall I overcome this...

    user9103174 wrote:
    Hi All,
    Im trying to connect to Oracle database from my windows command prompt, these are the steps I followed:
    1) cd C:\oracle\product\11.2.0\client_1\sqlplus
    2) sqlplus username\password@hostname:1521\service_name
    I do get the error ORA-06401: NETCMN: invalid driver designator
    I did try using the SQLPLUS \NOLOG
    Connect username\password@hostname:1521\service_name
    I still get the same error.
    I did manually type all the commands to make sure no additional charaters coming and etc...How shall I overcome this...do you desire/plan on using EZCONNECT or tnsnames.ora entry?
    EZCONNECT sample is below
    sqlplus user1/pass1@'dbserver:1521/orcl_sid'

  • Running eclipse java project on command prompt

    Hi all,
    I have one simple java project and that is very well running in eclipse. I have added some external JARs to that project. It performs this job- it creates connection to server, and listens to the signals from server.
    My question is - how do I run that java project on command prompt?*
    I want to run that using ANT or simply I want to make a JAR file so I can execute JAR on command prompt. I created JAR, but it doesn't contain external jar which I added to the project. So I was not able to run that project.
    Can you please tell me any of the method - using ANT or by making JAR?
    Also can you be little bit more explanatory in reply?
    Thanks

    I want to make a JAR file so I can execute JAR on command prompt.This is very likely a good way to proceed. It is explained in great detail in Sun's Tutorial in the section on [Packaging Programs in JAR Files|http://java.sun.com/docs/books/tutorial/deployment/jar/index.html].
    I created JAR, but it doesn't contain external jar which I added to the project. So I was not able to run that project.Yes - the jar file you create has to know about the classes and other resources in that external jar. Otherwise, at runtime, the program will not be able to get at the stuff it needs. Usually you don't include that other jar (or its contents) in the jar file you are creating. Instead you provide your jar file with a manifest that describes the other jar's location. Details are also in the tutorial.
    One thing to note is that Sun's tutorial provides a lot of explanatory, conceptual, material. To that end it keeps the context simple and transparent by describing the steps as they would be carried out by someone working at the command line. The Eclipse documentation and forums might provide a more click-this-drag-that "explanation". If you do follow the method in the Tutorial and get stuck, post a description of the actual commands you used and their outcome.

  • TDMS Defragment​-Through Windows Command Prompt

    Dear All,
    we need to Defragment the TDMS file  by TDMS Defragment.VI  via Windows Command Prompt.
    Work flow will be as below
    1.An Application wil be created to defragment using TDMS Defragment.VI
    2. When user stop Main Application (App 1) which records data for long time in tdms  ,the Main application (App 1)  will call defragmenting Application (App 2) via cmd and should get the file path and start defragmentation and it should pop a message defragmentation completed. and dont want Main Application  (App 1)  to do anything apart from triggering tdms defragmentation.
    Reason is We dont want the Main Application (App 1)  to wait for Long time till defragmentation and Since we need to use the Main Application (App 1)  for other testing.
    So we decided to do this defragmentationin in some other way  and display the completion message to user
    please provide suggestions 

    I'd also recommend doing this in one application.  If you truely want to do it from a command line you can.  LabVIEW built EXEs can support command line switches if you enable it in the build specificaitons.  If you do this you'll probably want to support multiple instances, and code it so that it will exit once the conversion is done.  But again you can get more information from the result of the defrag (like error) if you do it in the same application.
    Taki1999 wrote:
    EDIT: Asynchronously is difficult to spell
    Totally agree and some spell checks claim it isn't a word.  Same with programmatically.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • How java runs in command prompt and why java runs on it

    how java runs in command prompt and why java runs on it

    command prompt was used before the development of IDEs like RAD,eclipse etc.
    its still used for better understanding of the compilation and errors.
    type the java file and save the file(source file) in the bin folder of ur jdk environment with extension .java. the source file must be the one that has the main method declared.
    in the cmd prompt screen , set the path of bin folder.
    eg:C:/program files/jdk(some version)/bin/...
    for compilation,type:
    javac (source file_name).java and press enter
    for running the file:
    java source file_name

  • Log ConsoleHandler + Windows Command Prompt

    Having really strange problem:
    Program started from Windows Command Prompt.
    Logging with ConsoleHandler.
    If select something with "Edit->Mark" in this Command Prompt, process stop responding.
    Has anybody seen such behavior?

    Correction:
    Looks like anything writing to stdout/stderr hangs in Windows Command Prompt "mark" mode.
    Could not find anything about how it works.

  • How to get no. of rows of Windows Command Prompt in java

    hi all,
    can anybody tell me that is there any java utility avalilable throght I can find the how many rows avalilbe on currently executing command prompt, and also how can i clear the content of command prompt (result of 'cls' command).
    Currently execting command prompt means from where I have run my java program.
    any reference is also welcome.
    thanks in advance.

    Clearing the screen is trivial, as long as you're OK with making your program specific to Windows only (i.e. you never hope to run it on any other OS ever):
    Runtime.getRuntime().exec("cmd /c cls");As to figuring out how many lines your command window's screen buffer has - good luck with that. I'm not familiar enough with the Win32 API to get this info, but you'll have to figure out what that is, and call it via JNI.

  • Using java to run command line as %username%

    Hi all,
    can any one help with this?
    I'm trying to run a command line from a database as %username% in Windows. So far I have the following script, courtesy of Frank Naude to build a java class that is published within a plsql procedure. A command line can then be passed to it.
    rem -----------------------------------------------------------------------
    rem Filename: oscmd.sql
    rem Purpose: Execute operating system commands from PL/SQL
    rem Notes: Specify full paths to commands, for example,
    rem specify /usr/bin/ps instead of ps.
    rem Date: 09-Apr-2005
    rem Author: Frank Naude, Oracle FAQ
    rem -----------------------------------------------------------------------
    rem -----------------------------------------------------------------------
    rem Grant Java Access to user USER1
    rem -----------------------------------------------------------------------
    conn sys/password@database as sysdba
    EXEC dbms_java.grant_permission('USER1', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC dbms_java.grant_permission('USER1', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    EXEC dbms_java.grant_permission('USER1', 'SYS:java.io.FilePermission', '/bin/sh', 'execute');
    EXEC dbms_java.grant_permission( 'USER1', 'SYS:java.io.FilePermission','C:\WINDOWS\system32\cmd.exe', 'execute' );
    rem -----------------------------------------------------------------------
    rem Create Java class to execute OS commands...
    rem -----------------------------------------------------------------------
    conn user1/password@database
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host {
    public static void executeCommand(String command) {
    try {
    String[] finalCommand;
    finalCommand = new String[4];
    finalCommand[0] = "C:\\WINDOWS\\system32\\cmd.exe";
    finalCommand[1] = "/y";
    finalCommand[2] = "/c";
    finalCommand[3] = command;
    // Execute the command...
    final Process pr = Runtime.getRuntime().exec(finalCommand);
    // Capture output from STDOUT...
    BufferedReader br_in = null;
    try {
    br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String buff = null;
    while ((buff = br_in.readLine()) != null) {
    System.out.println("stdout: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_in.close();
    } catch (IOException ioe) {
    System.out.println("Error printing process output.");
    ioe.printStackTrace();
    } finally {
    try {
    br_in.close();
    } catch (Exception ex) {}
    // Capture output from STDERR...
    BufferedReader br_err = null;
    try {
    br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
    String buff = null;
    while ((buff = br_err.readLine()) != null) {
    System.out.println("stderr: " + buff);
    try {Thread.sleep(100); } catch(Exception e) {}
    br_err.close();
    } catch (IOException ioe) {
    System.out.println("Error printing execution errors.");
    ioe.printStackTrace();
    } finally {
    try {
    br_err.close();
    } catch (Exception ex) {}
    catch (Exception ex) {
    System.out.println(ex.getLocalizedMessage());
    show errors
    rem -----------------------------------------------------------------------
    rem Publish the Java call to PL/SQL...
    rem -----------------------------------------------------------------------
    CREATE OR REPLACE PROCEDURE host(p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    show errors
    rem -----------------------------------------------------------------------
    rem Let's test it
    rem -----------------------------------------------------------------------
    exec host('notepad');
    The trouble is although this script works great for commands that can be run is the 'background' as SYSTEM is I want to pass a command to actually open something e.g. notepad in the above example nothing seems to happen. As far as I can make out the command line is running but not as %username% so it's not running notepad.exe in the foreground.
    I'm happy to clarify more if necessary.
    Can anyone help with this?
    Cheers
    Yog

    Bill,
    Thank you for the quick answer. I believe you are right in your assumption.
    I have been searching but found nothing so far.
    I need to be able to run this line "wmic
    Product where name='XXX XXX XXX' call uninstall" 
    in an elevated command prompt to uninstall the program.
    I was looking for a VB script or PowerShell to execute it remotely on non domain roaming PCs.
    Th3e command can be run remotely against stand-alone workstations but you must supply credentials.  Post in the platform forum for you version of Windows for help in using the WMIC utility.  WMIC /? will give you all of the command options fro
    remote execution.  UAC only affects local systems.  You cannot use WMIC to remote back to the local system. WMIC does not allow impersonation to the local system.
    Most installers will not automatically allow an unattended uninstall.  If there is any dialog at all the uninstall will fail and can hang.
    I recommend contacting the vendor of the application to get more information.
    In all cases you cannot bypass UAC as Bill has noted.  I am only noting that, sometimes, in a workgroup, you can use WMIC to remotely uninstall an application.
    ¯\_(ツ)_/¯

  • Set Title of Windows Command Prompt Window

    I'm running a text-only Java application in a Windows XP Command Prompt window. Is there a way for my application to change the title of the window as it runs?

    GaryS wrote:
    I'm running a text-only Java application in a Windows XP Command Prompt window. Is there a way for my application to change the title of the window as it runs?no. command prompt actions in java are weak/nonexistent. probably due to the lack
    of cross platform similarities. you can always run your program using a batch file and
    set the title in there.

  • "java.lang.UnsatisfiedLinkError" happen when I use java.exe in command line

    When I use Eclipse 3.01 to run the program it has any problem.But If I use the command line "java -classpath D:\Java_prj\Java\NativeMethod\out com.bruce.nativemethod.HelloNative",a error message will appear below:
    java.lang.UnsatisfiedLinkError: no ./out/com/bruce/nativemethod/ in java.library.path
         at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1403)
         at java.lang.Runtime.loadLibrary0(Runtime.java:788)
         at java.lang.System.loadLibrary(System.java:832)
         at com.bruce.nativemethod.HelloNative.<clinit>(HelloNative.java:21)My HelloNative.dll and HelloNative.class has all been putted in D:\Java_prj\Java\NativeMethod\out\com\bruce\nativemethod.
    My all source code is here:
    //HelloNative.java
    package com.bruce.nativemethod;
    import java.util.*;
    public class HelloNative{
         public static native void greeting();
         //Load the library
         static {
              System.loadLibrary("./out/com/bruce/nativemethod/HelloNative");
              //System.loadLibrary("HelloNative");
         public static void main(String args[]) {
              HelloNative.greeting();
    //HelloNative.c
    #include "HelloNative.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL Java_com_bruce_nativemethod_HelloNative_greeting(JNIEnv* env,
        jclass cl)
        printf("Hello world!\n");
    //HelloNative.h
    //Generated by javah.exe
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class HelloNative */
    #ifndef _Included_HelloNative
    #define _Included_HelloNative
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     HelloNative
    * Method:    greeting
    * Signature: ()V
    JNIEXPORT void JNICALL Java_HelloNative_greeting
      (JNIEnv *, jclass);
    #ifdef __cplusplus
    #endif
    #endifI thinked the code is not problem.But why I can't not run it use java.exe tool in command line?

    Thanks everybody! My problem has been solved.The path "./out/com/bruce/nativemethod/HelloNative" is right because it can run in Eclipse 3.01.I don't agree use the absolute path.If do so,it may not use in another machine. The problem is when I use the "java -classpath D:\Java_prj\Java\NativeMethod com.bruce.nativemethod.HelloNative" in the command line windows,I have putted it the C:\ directory to excute.laterly,I putted the command in the D:\Java_prj\Java\NativeMethod,the result "Hello world!" is appear.

  • Javac command in windows command prompt

    Hi, i would just like to know how i can enable the javac command in the command prompt of windows without being in the java/bin directory...i have tried env. variables and stuff but to no avail, however the java command work.
    Thanks Rudy
    ps does anyone know any good rmi tutorials which are easy to follow, thanks.

    Err, nm, just reread that.
    The environment Path is the way to go.
    Just add the bin directory to the end of the PATH in the advanced option of my computer. You may need to reboot.

Maybe you are looking for

  • Purchase Order Updating by Due Date

    Dear Sirs, I am testing purchase orders commitments in payment budget with update profile 000202. This UP updates postings by due date as standard. To reinforce it I market as due date at OF39 to Value Cat. 51. However system is still updating POs po

  • Calendar on iPhone & MacBook not syncing correctly

    I have lost various items from last year from my iPhone calendar, they do appear on my MacBook. I entered some of the old items again as I needed them for reference, they appeared OK but when I went to the next date to do another entry and came back

  • How do i re-open my tabs when i re-open firefox

    when ive worked on firefox and i close the program, then when i re-open i would like the previous tabs opend again

  • Welcome-file ignored?

    The application does not take the welcome-file specified in web.xml into account.      <welcome-file-list>           <welcome-file>home.jsp</welcome-file>      </welcome-file-list> I tried with home.jsp, /home.jsp, home.jsf and /home.jsf, but without

  • Itunes needs a random shuffle option

    Well the subject says it all! Shuffle seems to play the same songs and no one has an answer in other post.