Running Java Program via bat file

Hi
I have a bat file. I have compile the java files and the class files into the same folder.
I am suppose to double click on the bat file and it is suppose to run (in the same manner as IDE)
but it only appear the 1st line of the program. Whatever i type, it refuse to budge.
What should i do to retify the problem?
I have already set the classpath properly

Hi
I just realised that my program can only run halfway on the dos...
This is my code sample
try{
            pw = new PrintWriter("TS.log");           
            System.out.println ("hi");
        catch(IOException io){
            io.printStackTrace();
        try {
            StandAloneApplication = true;
            String[] a = new String[1];  
            System.out.println ("hi2");
            Settings settings = Settings.getInstance();
            StringTokenizer letterToken = new StringTokenizer(settings.get("letter"),",");
            Vector <String> v = new Vector<String>();
            while(letterToken.hasMoreTokens()){
                v.add(letterToken.nextToken());
            String letter[] = v.toArray(new String[v.size()]);
            System.out.println ("hi3");
            DbConnection d = new DbConnection();
            String stocklist = d.getStockList();
            String mainFile ="";
            GenerateSLS sMain = new GenerateSLS("timeSales.sls");                                               
            String sessionID = d.createiFisSession();                      
            System.out.println ("hi4");
            for(int i=0;i<letter.length;i++){
                System.out.println ("print");
                mainFile = sMain.start("timeSalesGen"+letter[i]+".sls",d.getStockList(letter[i]+"%.SI"),sessionID);
                a[0] = mainFile;       
                staticArguments = a;       
                Viewer viewerMain = new TSMainCapture();       
                viewerMain.init();          
                viewerMain.start();it stops printing after "hi4"
btw, I have tried to run this on the bat file again.
IDE side retest, re-compile and rerun, work well
Pls help
Thanks.
Lots of appreciation

Similar Messages

  • How to get the erroe message, if i run java program using .bat file

    Hi,
    I have a java file which accepts two inputs as command line argument. I want to make this pgm a tool. So have created a *.bat file which has the following command
    java myprogram arg1 arg2
    I'm gonna share this program with others. So i'll keep the class file and the .bat file in a commaon folder. All the users have to do is, edit the .bat file to give his/her args and run the .bat file. The pbm is, if the user input is not valid, I have put displays in the pgm to show it.
    But if i run thru .bat, I'm not getting the error message or I don't know where it is getting displayed.
    Can anyone help me with this ?
    Thanks,
    Mary

    When i run from the console, I can see the output.
    But, when i double click on the .bat file from the
    folder, it runs fine and i couldn't see the output.
    nullThat's because the error message is printed, and then the console is closed. The message is there but you need to read really really fast :)

  • Compile and run java programs using batch file

    i am using eclipse to run my java programs.How to compile and run those programs using a batch file?

    a) just write a batch file, and add it to the project. When you want to run it, go to a command window and invoke it. (There is probably also a way to invoke it from Eclipse)
    b) if the project is complicated, take a look at ant. Eclispe knows about ant files.

  • Open a file in a running java program via double click

    I have already implemented opening my program with the corresponding file after a double click in windows explorer or from the cmd line but how do you open a file into the program if it is already running as MS Word will open a .doc file in the current word instance if you are running it.
    Thx,
    Jim

    Implement some sort of interprocess communication in your program. If you launch an instance, it can check whether another is running and pass a message to it telling it to perform the wished action.

  • Running Java classes via .cmd files

    Hi. I've a few Java classes which need to be executed every so often. I've wrote a .cmd file:
    G:
    cd G:\j2sdk1.4.2\bin
    java utils.verifier
    When it executes it successfully runs the java class but I want the cmd window to stay open? becuase when the cmd file finishes runnning it closes the window. How do I make it stay open? Could I slightly modify my verifier class to request some input, so it keeps the window open?Thanks

    Alternatively, you can tweak the cmd rather than pausing it.
    Check cmd/? for more info, I believe it was /K option

  • Run java program on linux

    Hi All
    I'm beginner with linux
    I have java program and I can run it in windows7 with bat file
    jre1.6.0_04\bin\java -classpath "..\classes"  database_com.Main_Class 7778
    pauseI want to run this program in linux but I can't
    I try run this program with bat file :
    /java-1.5.0-gcj-4.3-1.5.0.0/bin/java -classpath "../classes"  database_com.Main_Class 7778
    pauseplease help me

    Ora-dbaabode wrote:
    I want to run this program in linux but I can'tImagine you have a splitting headache and decide to go to the doctor. You come into his (or her) office and say, Doc, I'm not feeling to well. The doctor replies and asks, well, what seems to be the problem? You reply: "well, I just don't feel too good". See where I'm getting at (hint: missing details!).
    As for your JDK, I highly, no, I very highly recommend you get rid of GCJ and install Sun's JDK. This may very well be the source of your problems. GCJ is a pain in the @ss!

  • Running java program at windows startup

    I need to run java program at startup and then it will continue to run in its own thread.
    Any body having idea how to do that programmatically?
    Zeeshan

    This is one option but this is not feasible in my scenario as this application will be running over a network which involves hundreds of computer so is there any way to do it programatically?
    I mean if I can load java class file through an exe file then I can load my class file in the startup using C++.
    Any Suggestions.
    thanks for the help
    regards,
    Zeeshan

  • How to Set up the  variables and others to compile and Run Java Programs

    Hello,
    I have just downloaded the jdk1.6.0_07 and jre1.6.0_07 and installed it in C:\Program files\Java in my Windows XP ,So please tell me how to sett up the enviroment variables etc to compile and run Java Programs from Command Prompt.
    thanks

    To set the PATH permanently, add the full path of the jdk1.6.0_<version>\bin directory to the PATH variable. Typically this full path looks something like C:\Program Files\Java\jdk1.6.0_<version>\bin. Set the PATH as follows on Microsoft Windows:
    1. Click Start > Control Panel > System on Windows XP or Start > Settings > Control Panel > System on Windows 2000.
    2. Click Advanced > Environment Variables.
    3. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for PATH is:
    C:\Program Files\Java\jdk1.6.0_<version>\bin

  • Compile and run java programs in different directroy

    Hi,
    I often encounter many problems when I run java programs in the different directories. Like
    javac -d dir_name a.java
    java -cp dir_name a
    Something wired often happens, such as, there is not a.java file in some directory, but javac -d dir_name a.java can still work or "java -cp dir_name a" often doesn't work. Moreover, file_name.jar is also a tough problem and solving compiling problems is often time-consuming.
    So I hope to read something about how to compile and run java programs in different directory properly.
    Could you pleae give me a detailed description for that or recommend a book or website?
    Thanks a lot.

    Can you post a small amount of code that does not work, including the directory structure, and the error messages? Some one here can likely explain the problem.

  • I want to run java program on windows environment as background process

    Hi all
    I want to run java program on windows environment as background processSo command prompt return after executing java command and program on background In Linux we can do this easily �but I do not how to do this in windows
    for example look this programe
    import java.io.*;
    import java.util.*;
    public class TestClass {
         class ravi extends Thread{
              public void run(){
                   try {    
                        String target_file = "ravind.txt";
                        File targetfile = new File(target_file);
                        PrintWriter writer = new PrintWriter(new FileWriter(targetfile)) ;
                   for (int i =0 ; i < 100 ;i++ ){
                        Thread.sleep(10000);
                        writer.println(" ravindra shukla ");
              } catch (Exception e) {               
                             e.printStackTrace();
         public static void main(String[] args) {
              TestClass test1 = new TestClass();
              TestClass.ravi r1 = test1.new ravi();
              r1.start();          
    System.out.println(" return from main ");
    first i compile this
    javac TestClass.java
    then i run this by using this command
    java TestClass
    but becouse i put sleep on threads run function so it takes to much time to get return on command promt .... i want to run this programe as background process so command promt return as soon as i execute java command

    Thanks dude
    This solution �start java TestClass� works fine �. But it does not solve my problem
    It opens another black window and that black window persist till the life time of my program
    Is it possible application run on complete background without opening another black window �as in Linux

  • Can't Run Java Programs -- java.lang.NoClassDefFoundError Error

    I am running 10.4.11. For some reason I can no longer run Java programs. (I could in the past)
    For example. I create a simple Hello World program as follows and save it as Hello.java:
    class HelloWorld
    public static void main (String args[])
    System.out.println("Hello, world!");
    Then I compile it:
    Javac Hello.java
    Then I try to run it:
    java Hello
    But I get this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: Hello
    I think it must be a CLASSPATH problem but normally you do not need to worry about ClassPATH. Apple sets it up for you out of the box.
    What is wrong?

    I totally forgot that the class name should be the same as the filename.
    After I renamed the file to HelloWorld.java and recompiled, I could run "java HelloWorld"
    Rob

  • Reg:Unix shellscripts running java programs

    hi,
    We are using unix shell scripts , by running that script it will execute some java programs.
    when we running shell scripts, which executes the programs it is generating some log files ie some error is occuring.
    i want to why these files are generating
    Thanks and Regards,
    Meer S.

    HI ,
    we are running the shell script which runs java programs,
    we are getting the result no problem ,
    but it is generating the unwanted ORBTRC files
    we are using websphere application server.
    we donot want these orbtrc files.
    HOW CAN WE DISABLE THE FILES
    pls guide this.
    Thanks and regards,

  • Vim and Eclim (Java): Run Java program in embedded terminal window

    Hello all,
    I'm trying to create a decent Vim setup for Java programming. I've installed Eclim, and it works alright. However, one annoyance I have is the way that Eclim runs Java programs. When run (via the :Java command in Vim), a Java program runs in a new shell instance pretty independent from Vim, and then when the program terminates (and Enter is pressed), the output is put into a new buffer at the bottom of the Vim window with the output.
    The problem with this is that I must press Enter to go back to Vim after the program terminates, and then the output buffer is automatically selected even though I most likely do not care to copy any of the output.
    So, this is what I would like to happen:
    - I run my Java program somehow (doesn't have to be with :Java)
    - A buffer containing the running program in a shell is put on the screen (if not already there)
    - The program terminates, and the focus did not change to the output buffer
    At the very least, I want the focus to not change to the output buffer after the program is done running.
    Any ways to at least somewhat accomplish what I'm trying to  get at?

    Trent wrote:
    Yeah? I had AP CS when they first introduced the GridWorld case study. I hope you get more out of the class than I did.
    I have never used Java except for that and my first CS class at university. I eventually realized that software (as a job) wasn't for me and took a route closer to EE. I still fight to avoid being called a programmer though
    I like the idea of programming for a job, not necessarily "software development", something computer science-y sound good to me.
    But anyway, to end on an on-topic note, I embedded gvim inside Eclipse as described here.

  • Can't run java program with GUI

    My computer can run java program properly.
    However, for those program with GUI (using swing),
    my computer is unable to display the GUI.
    What's wrong with it? Is there any PATH I need to set before running GUI program?
    Thanks
    icedgold

    Cut, copy, paste then compile and run this;-import java.awt.*;
    import javax.swing.*;
    public class MyJFrame extends JFrame {
      public MyJFrame() {
          super("My first JFrame");
          Container c  = getContentPane();
          JPanel panel = new JPanel();
          panel.setBackground(Color.white);//  (new Color(255, 255, 255));
          JLabel jl = new JLabel("Yes it works");
          panel.add(jl);     
          c.add(panel);
      public static void main(String[] args) {
        MyJFrame frame = new MyJFrame();
        frame.setSize(180,120);
        frame.setLocation(200, 300);
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setVisible(true);
    }

  • Run java program in background

    I want to run a java program in background in windowsXP...can anyone help please......can anyone suggest an easy software for running java program as windows service...i tried one but without any success

    How many of the links here have you tried while you were waiting for an answer?
    http://www.google.com/search?q=running+java+program+as+windows+service
    (Note that the query is a direct copy/paste from your post.)

Maybe you are looking for

  • Using godaddy to host my iweb (2.0.4) website

    After talking to godaddy, they convinced me that I should have my site hosted by them, Sounded good. They said iweb would work fine. Well, it does not work. I upload the files I created in iweb three times. The first page shows up fine, but the links

  • Swing Framework Suggestions

    Hi, I'm new to Swing and am looking for a good book and/or white paper on the correct way to structure a swing application in JDK 1.6. There are a lot of ways to do things but I'm looking for suggestions for the simple stuff: best way to start up and

  • Bout 6230i profile

    Hi to all... My costomer was bout to buy 6230i frm me. But I faced the prob. is... when i change da profile tune it works fine.. If switch it off nd on it goes to orginal nokia tone. I checked in both language Arabi nd English.. But found da same pro

  • Photos disappeared after renaming them

    My photos on photobooth disappeared after I renamed them. I clicked on "reveal in finder" and after I renamed them, I could no longer find them. Any idea where I should look?

  • How open app excel or pdf from oracle form

    Hello, i want to open Excel program or accrobat when i press on the button , i wrote this code DECLARE AppID PLS_INTEGER; BEGIN AppID := DDE.App_Begin('C:\Program Files\Microsoft Office\OFFICE11\excel.exe', DDE.App_Mode_Minimized); END; but nothing d