How to abend the java program -if the condition fails

Hi
My program counts the number of headers in the input file and if the condition fails to satisfy the number we expected , it should comeout of the java program . Is their a specific statement to abend the program in java .
if(columnCount == 5)
// do all the steps
else
//abend the program }
how to do that .... is it System.exit(1) or anything else
thanks..
Edited by: 1sai on Apr 23, 2009 6:52 PM

BigDaddyLoveHandles wrote:
It must have been that the [card sorters|http://en.wikipedia.org/wiki/Card_sorter] were making such a ruckus that I didn't hear it. The model 84 -- 2,000 cards a minute? -- dämn, that's sweet.
I remember the first time I saw a card sorter in action, thinking it was kind of cool.
I also think the teacher used it to describe some sorting algorithm, maybe radix sort??
You've got me thinking, that might be part of the problem with computing today, not enough moving parts. No big tape drives spinning and oscillating. And few if any line printers anymore. Now there's an interesting piece of equipment.

Similar Messages

  • How to put a Java Program into the System tray

    Hi all of the forum!!
    I have a question. I want to make a monitor program but I don't know how to put the program in the system tray or just to execute the program but automatically (no manual execute), but i dont want that the program appear in a window, just start to function when i start my PC. i hope anybody help me.
    Thanks
    Best Regards
    Bucio, Francisco

    There is a plenty of similar topics here, so you can use the Search on this forum or in Google to find out.
    But shortly, you will need to use JNI or get a ready-to-use library like JNIWrapper (http://www.jniwrapper.com/winpack.jsp#tray), for example, that lets you do what you want.
    Good luck,
    EToporov

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

  • How to run a java program in the JVM of an already running program?

    As far as I know about JVM, each time we run a program a separate instance of JVM is created where the program runs. Correct me if I am wrong.
    Is there any way for another program to execute itself in the same JVM?
    Currently I am working on JFCUnit which is a tool used to automate swing applications. I am trying to automate JConsole.
    If I open "JConsole.exe" through a program and then try to get the handles using JFCUnit, things are not working.
    If I use JConsole.jar in JDK/lib and create a new instance of JConsole and then try to get the handles using JFCUnit, I am able to proceed with automation.
    But here comes the problem :-
    The application which needs to be automated through JConsole requires it to be started with few arguments, which is as follows:
    %JDK_HOME%\bin\jconsole -J-Djava.class.path=%CLASSPATH% -J-Dcom.sun.management.jmxremote.ssl=false -J-Dcom.sun.management.jmxremote.authenticate=true -J-Djmx.remote.protocol.provider.pkgs=oracle.oc4j.admin.jmx.remote "service:jmx:rmi://localhost:23791"So this problem can be solved in two ways,
    Either
    1. JFCunit could be made to recognize the JConsole.exe which would be running is a different JVM.
    OR
    2. JConsole.jar to be used in a way so that it takes the required arguments, hereby an instance of JConsole would be created that too in the same JVM as that of the program.
    I am more interested in the first solution as it would definitely be helpful in other projects as well.
    Please let me know if any other solution is possible.
    Any kinda solution is appreciated :)
    Thanks in advance.

    Give a look at Terracota.
    http://www.terracottatech.com/

  • How to begin learing Java Programming for the Internet?

    expecially for socket

    Just go to www.google.com and search for java+server+client+socket
    And then look at some source code...

  • How to run a java program remotely

    hi,
    i have a simple hello-world java program on my windows machine.
    is it possible to run this program remotely from a linux server?
    any suggestions, links to suggestions will be helpful. thanks!

    i think that would be a problem for me, so i will need to use some other approach. what i'm trying to do actually is that we have a university server which is set up so that students can have combination fo shell and cgi scripts in their home directory and with that, they can have web pages.
    but students cannot use that server to run java applications. so to work around that, i was hoping that i can have my java application, and the database on my own windows machine, and be able to invoke the java program from the shell script on the linux server and once i have my ouptut, i can display that on the web page with CGI script.
    is there any other practical approach that i can use to accomplish the above?

  • How to execute a java program in business objects

    I am new to  java world, we r passing parameters  thru java program. The java program passes the parameters(like state) dynamically to crystal reports to generate the reports indivudually for evey parameter(like ca,ny,fl) . what r the things i need to configure in the business objects in order to use java program to pass parameters to the reports which r scheduled in cmc.
    if any one has any materials which will be helpfull  post here

    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/unix.html

  • How to write a JAVA program to execute the SQL queries

    I have a database in the Microsoft Access queries and I need to execute the query by some how write the Java program to make it execute the query. because I need to get the different of time so I know how fast each query run.
    Thank you

    You need jdbc-driver for MSAccess for run this example:
    JDBCClient.java
    import java.util.Properties;
    import java.lang.String;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.BufferedOutputStream;
    import java.lang.System;
    import java.lang.Class;
    import java.sql.SQLException;
    import java.util.Date;
    import java.util.Locale;
    import java.text.DateFormat;
    import java.sql.Time;
    public class JDBCClient{
        private String DriverName = new String();
        private String DatabaseURL = new String();
        private String UserName = new String();
        private String Password = new String();
        private String SQLFile = new String();
        private String OutputFile = new String();
        private String Separator = new String();
        private boolean NeedColumnHeaders;
        private String EncodingParamName = new String();
        private String EncodingValue = new String();
        private String OutputEncoding = new String();
        private boolean AfterLastColumnSeparator;
        JDBCClient( String propfilename){
         System.out.println( "Initializing...");
         Properties properties = new Properties();
         try{
             properties.load( new FileInputStream( propfilename));
         catch( Exception e){
                 System.out.println( "Error: " + e.toString());
             System.exit( 0);
         DriverName = properties.getProperty( "DriverName");
         DatabaseURL = properties.getProperty( "DatabaseURL");
         UserName = properties.getProperty( "UserName");
         Password = properties.getProperty( "Password");
         SQLFile = properties.getProperty( "SQLFile");
         OutputFile = properties.getProperty( "OutputFile");
         Separator = properties.getProperty( "Separator");
         if( properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "yes") == 0 ||
             properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "true") == 0)
             NeedColumnHeaders = true;
         else
         if( properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "no") == 0 ||
             properties.getProperty( "NeedColumnHeaders").compareToIgnoreCase( "false") == 0)
             NeedColumnHeaders = false;
         else{
                 System.out.println( "Invalid value for \"NeedColumnHeaders\" property (logical expected)");
             System.exit( 0);
         EncodingParamName = properties.getProperty( "EncodingParamName");
         EncodingValue = properties.getProperty( "EncodingValue");
         OutputEncoding = properties.getProperty( "OutputEncoding");
         if( properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "yes") == 0 ||
             properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "true") == 0)
             AfterLastColumnSeparator = true;
         else
         if( properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "no") == 0 ||
             properties.getProperty( "AfterLastColumnSeparator").compareToIgnoreCase( "false") == 0)
             AfterLastColumnSeparator = false;
         else{
                 System.out.println( "Invalid value for \"AfterLastColumnSeparator\" property (logical expected)");
             System.exit( 0);
         try{
             byte[] EOL = new byte[2];
             EOL[0] = 13;
             EOL[1] = 10;
             Class.forName( DriverName);
             Properties connInfo = new Properties();
             connInfo.put( "user", UserName);
             connInfo.put( "password", Password);
             if( EncodingParamName.length() != 0 && EncodingValue.length() != 0)
              connInfo.put( EncodingParamName, EncodingValue);
                 Connection connection = DriverManager.getConnection( DatabaseURL, connInfo);
             FileInputStream in = new FileInputStream( SQLFile);
             byte[] buffer = new byte[in.available()];
             in.read( buffer);
             in.close();
             String SQL = new String( buffer);
                 PreparedStatement statement = connection.prepareStatement( SQL);
             Date d1 = new Date();
                 System.out.println( "Database connected at " + d1 + " Executing statement...");
                ResultSet resultSet = null;
             if( statement.execute())
              resultSet = statement.getResultSet();
             else{
                  System.out.println( "Script updates " + statement.getUpdateCount() + " records.");
              System.exit( 0);
                 ResultSetMetaData metaData = resultSet.getMetaData();
                 BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( OutputFile));
             if( NeedColumnHeaders && metaData.getColumnCount() > 0){
              String head = new String();
              for( int i = 1; i < metaData.getColumnCount(); i++)
                  head += metaData.getColumnName( i) + Separator;
              head += metaData.getColumnName( metaData.getColumnCount());
              out.write( head.getBytes( OutputEncoding), 0, head.length());
              out.write( EOL, 0, 2);
             String record = new String();
             while( resultSet.next()){
              record = "";
              for( int i = 1; i < metaData.getColumnCount(); i++)
                  record += resultSet.getString( i) + Separator;
              record += resultSet.getString( metaData.getColumnCount());
              if( AfterLastColumnSeparator)
                  record += Separator;
              out.write( record.getBytes( OutputEncoding), 0, record.length());
              out.write( EOL, 0, 2);
             out.close();
             Date d2 = new Date();
                 System.out.println( "Done at " + d2);
                 System.out.println( "Executing time " + new Time( d2.getTime() - d1.getTime() - 10800000));
         catch( ClassNotFoundException e){
                 System.out.println( e.toString());
         catch( SQLException e){
                 System.out.println( e.toString());
         catch( java.io.IOException e){
                 System.out.println( e.toString());
         System.exit( 0);
        public static void main( String args[]){
         if( args.length == 1)
             new JDBCClient( args[0]);
         else
             System.out.println( "Usage JDBCClient <properties_file>");
    }JDBCClient.properties ( for Oracle database)
    DriverName=oracle.jdbc.driver.OracleDriver
    DatabaseURL=jdbc:oracle:thin:@192.168.1.1:1521:test
    UserName=test
    Password=test
    SQLFile=test.sql
    OutputFile=test.csv
    Separator=*
    NeedColumnHeaders=yes
    EncodingParamName=
    EncodingValue=
    OutputEncoding=windows-1251
    AfterLastColumnSeparator=yestest.sql
    select * from users;

  • How to write the java program to retrieve the last 7 days dates

    Hi,
    I am having requirement that how to write the java program to retrieve the last 7 days dates. Please help me.
    Regards,
    Ahamad

    It needs any jar file.Of course!
    I did using jscape.My program is running fine.But it
    requires jar file.Which is licensed version.Maybe you should follow the link the the 'license' on the site I posted!
    >
    I have the doubt is apache provides jar file free
    versionMaybe you should follow the link the the 'license' on the site I posted!

  • How to invoke the .bat(batch file ) from the java program

    i want to run some commands when i run one java program.
    I wrote those dos commands on the batch file and i want to include the bat file in the java program so that i can execute the bat file when i run the java program.
    tell me the way that i can run my bat file inside the java program.

    i tried this :
    a .bat file named test.bat, with this code : copy test.bat test2.bat
    a java class, Test.class, in the same directory
    public class Test {
         public static void main(String[] args) {
              try {           
                   Runtime rt = Runtime.getRuntime();
                   Process proc = rt.exec("cmd /c test.bat");
                   proc.waitFor();
                   int exitVal = proc.exitValue();
                   System.out.println("Process exitValue: " + exitVal);
              catch (Throwable t) {
                   t.printStackTrace();
    }

  • Running the Java program as service.

    Hi,
    I want to create have java program, which runs continously. This would hit check a table in Database for any new records and if there is anything it would post a message to another service. It would keep track of how many messages were posted and how many were completed at any point of time.I should have the ability to stop this service. When a stop sequence is initiated, it should wait till all the messages are processed and shutdown. I am looking for inputs on how to invoke the java program as service and the second part (stopping the service). I dont want to Java wrapper service or commons daemon api. I am on JDK 1.4.2
    Thanks in Advance.
    Regards,
    Arul.

    Do you want to write a daemon? I dont think you can do it without some explicit OS support..
    Well, lemme know if you find a way

  • Java Programming @ SAP - the poor cousin?

    Hi!
    Recently I' ve started a kind of poll in the Java forums asking if someone knew any enhancement possibilities for java-side development at SAP mentioning the ABAP customer exits, BADIs, customer includes and enhancement spots as example.
    Guess how many answer I received - from WDJ, Java Programming, NWDI and NW Java from: None! All the gurus who usually bubble over with wisdom remained wondrous silent. I also run over help pages searching for some hints regarding this - in my opinion fundamental - questions, with the same result.
    Has really nobody at SAP spent a thought about one of the most precious features SAP offers its customers - the possibility to enhance delivered standard-programs and thereby adapt them to their needs without modification?
    How are we as Java programmers then supposed to stand the mistrustful glances of our ABAP collegues who wonder why there has been so much noise about this Java thing in the recent years. Thinking about the disadvantages a developer working with Java at SAP has to bear compared to his ABAP collegue - no direct data access, no comfortable debugging possibilities, lots of standalone tools with strange UIs (SDM Remote GUI, Visual Admin - only to name the least glorious ones - he to manage and - last, not least - no chance to enhance SAP Standard programs modification free I have to agree upon one ABAPers opinion on Java: "The hype is over!".
    Regards from a very pessimistic Java Developer
    Thomas
    PS: Does anybody know a way to unbureaucraticly swap a Java certification against an ABAP one?

    I get the question - should I do my development in ABAP or Java - quite often. My answer has become "It Depends."  I getting pretty good at those ambiguous consulting answers, aren't I.
    In all seriousness I really do think the answer depends upon several things.  As a company or development group you should analyze the skills that you already have in house.  As you have seen the two development environments are quite close.  The advantages of one over the other will continue to vary over time.  ABAP will add nice features from Java and vise versa.  In the end it is more important that companies leverage their skill sets and existing infrastructure (Software Lifecycle Landscape) to their maximum. 
    If you are already a java shop then it makes sense to continue down that development path because your developers will still be very efficient even if they have to access ERP and other SAP application logic and data via RFC or Web Services. 
    On the other hand, ABAP certainly isn't as dead as some people claimed it would be by now. Thanks to Web Services ABAP has more flexibility than ever before.  It isn't nearly the closed box that it used to be.  Also the workbench team isn't going to stop innovating either. 
    The next question I get is what does SAP do internally when deciding on a language to use.  To a large extent they use the same criteria - what existing skill sets do I have to work with.  They also look at where the data is located. 
    That means products like Portal aren't about to change from Java to ABAP.  On the other hand ERP suite development is still heavily ABAP.  The new UIs coming from ERP will primarily be done in Web Dynpro ABAP. 
    Even in some newer products that haven't been released yet - the UI was done in Java or Visual Composer and the backend business logic was done in ABAP. It is all about taking advantage of the unique strengths of each environment and the skill sets you have in each.
    In the end I don't think Java is the poor cousin any more than ABAP is going to die.  Look at NetWeaver CE and the huge investment SAP has made on top of Java Development there.  At the same time our investment in Java has not come at the cost of the ABAP environment.  Innovations will continue to take place there as well.  I can assure you that within SAP it is the hope and goal to have two top notch development environments within NetWeaver.
    Now let me share a little story with you.  My background is obviously ABAP and I doubt I will ever lose my particular passion for the environment.  At the same time I have done a fair bit of NetWeaver Java development in the last year and half or so.  I'm not a super deep expert, but I can hold my own. 
    I recently had a requirement to build an MDM Application.  I only had two days in which to build it.  My choices were to use the Java API or the ABAP API.  They are quite similar and both meet all my interface requirements.  I was building a Web Dynpro UI, so the end user wouldn't be able to tell the difference.  Interfacing capabilities being the same and UI output being identical - my decision came down to the environment where I personally could be most efficient.  I could have completed the project in either environment.  But because I knew the ABAP Programming Environment (you know the stuff that goes beyond the basic syntax - the real knowledge that lets you squeeze every last drop of performance out of an application) so well I personally could build the best application in the shorter time in ABAP. 
    Now someone with a different background might well have taken the Java path and done just as well.  This is the advantage that SAP provides by continuing to support both ABAP and Java development.  Does every feature and function of both environements line up exactly - of course not.  I'm sure they never will.  But do these differences keep experts in either environment from being able to make any application do amazing things - certainly not.  Personally I feel less constrained in either ABAP or Java today than I have ever felt programming before.

  • Is it possible to run the java program without main?

    Hi,
    Is it possible to run the java program without main?
    if anybody know please tell me, how it is possible.
    Regards,
    Ramya

    Hi,
    Is it possible to run the java program without main?
    if anybody know please tell me, how it is possible.
    Regards,
    RamyaWhy do you ask? It sounds like an odd question. Your program can be an applet and it doesn't need a main method in that case.
    Kaj

  • Need to change the directory using the java program

    hi,
    can anyone give me the code to change the directory in the java program by using the system command.
    as in C where we use the system call system("cd");
    the same way how to do that in java. please help me with that!!!

    Please search the forums for "runtime.exec", there are dozens of examples posted.
    Although this may not do you any good, since changing the os's directory is not likely to change anything you're using in Java. What are you trying to do?

  • 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

Maybe you are looking for