Pass the string as params from a Java application to another

I'm moving a String as a parameter to a Java Aplications of a second as a startup parameter

for example I have applications that must call start another Java application (just contains only JOptionPane, simple JFrame or JDialog) before System.exit (0); I'm trying to send some descriptions to close the application to another.

East of simulations of what these codes I tried this and in this form, the code works correctly and displays the string in the JTextArea...
import java.io.IOException;
    import java.util.concurrent.*;

    public class TestScheduler {

        public static void main(String[] args) throws InterruptedException {
            ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10);
            executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
            executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(true);
            for (int i = 0; i < 10; i++) {
                final int j = i;
                System.out.println("assign : " + i);
                ScheduledFuture<?> future = executor.schedule(new Runnable() {

                    @Override
                    public void run() {
                        System.out.println("run : " + j);
                    }
                }, 2, TimeUnit.SECONDS);
            }
            System.out.println("executor.shutdown() ....");
            executor.shutdown();
            executor.awaitTermination(10, TimeUnit.SECONDS);
            try {
                Process p = Runtime.getRuntime().exec("cmd /c start java -jar C:\\Dialog.jar 'Passed info'");
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            System.out.println("System.exit(0) .....");
            System.exit(0);
        }

        private TestScheduler() {
        }
    }

//
import java.awt.*;
import java.util.ArrayList;
import javax.swing.*;

public class Main {

    private static ArrayList<String> list = new ArrayList<String>();

    public Main() {
        JFrame frm = new JFrame();
        JTextArea text = new JTextArea();
        if (list.size() > 0) {
            for (int i = 0; i < list.size(); ++i) {
                text.append(list.get(i));
            }
        }
        JScrollPane scroll = new JScrollPane(text,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frm.add(scroll, BorderLayout.CENTER);
        frm.setLocation(150, 100);
        frm.setSize(new Dimension(400, 300));
        frm.setVisible(true);
    }

    public static void main(String[] args) {
        if (args.length > 0) {
            for (String s : args) {
                list.add(s);
                System.out.print(s + " ");
            }
        }
        Main m = new Main();
    }
} 
My question:

whether is there another way to pass a value to a Java application (it should be called System.exit (0);) to another Java application, another way I tried using process/ProcessBuilder

My crospost http://stackoverflow.com/questions/6121990/pass-string-as-params-from-one-java-app-to-another

Yes, there are other ways. Is this way do not meet your needs?

1. There is another exec() signature that accepts an array where the first element is the command and the rest of the elements are its args. It may or may not be a varargs call. That looked something like this, but it might not work exactly as I.

exec("cmd", "/c", "start", "java", "-jar", "C:\\Dialog.jar", "Passed info");
// OR
exec(new String[] {"cmd", "/c", "start", "java", "-jar", "C:\\Dialog.jar", "Passed info"});

2. you can place the information in a file that the second process reads.

3. you can store information in a database that the second dealing with applications.

4. you can have a single process open a ServerSocket and either connect to it and send the data in this way.

5. you can use a higher level like Active MQ, JMS messaging tool, etc.

6. you can use the RMI.

7. you can use CORBA.

I don't know that there are other approaches as well.

I have no idea to the approach that is best for your needs. It's something that you need to understand, if you do decide, if you view details about your needs here, someone can offer some advice.

Tags: Java

Similar Questions

  • I have my old laptop work, admin access, and I need to pass the parameters of language from German to English, especially the menus. Can you please indicate.

    I have my old laptop work, admin access, and I need to pass the parameters of language from German to English, especially the menus. Can you please indicate.

    A.I have changed the time zone.

    But I can't understand how to move to the menus in ENGLISH and the keyboard settings. They are in German. Need urgent help

    The system is running on Windows XP Professional

    Thank you for your help in advance.

    (Yes the multi language pack is somewhere on the laptop... where I'm not sure)

    Hello

    1. - you want to say that you have an administrator access on this computer?

    2. What is the operating system default language when the laptop was purchased?

    If the default language is German so it is not possible to change it to English.

    Reference: to change the language used for menus and dialog boxes

  • By passing the string to a slider as a parameter

    Hello
    need help

    Version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    DECLARE
         lv_dept VARCHAR2(100);
         Currec EMP%ROWTYPE;
         Cursor Cur_Dept(pv_dept VARCHAR2) IS SELECT * FROM EMP WHERE to_char(deptno) IN (pv_dept); 
    BEGIN
       lv_dept:='''10'''||','||'''20''';
           OPEN Cur_Dept(lv_dept);
       LOOP
            FETCH Cur_Dept INTO Currec;
                     Message(Currec.Ename||Currec.deptno); --Forms code
          EXIT WHEN Cur_Dept%NOTFOUND;     
       END LOOP;
       close Cur_Dept;
    END;     
     
    If I pass the parameter as a string, it does not.

    Kind regards
    Franck

    As others have said, avoid using dynamic SQL statements.

    As SQL running in SQL * Plus, something like that...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select *
      2  from emp
      3  where deptno in (
      4                  with t as (select '&dept_numbers' as txt from dual)
      5                  select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
      6                  from t
      7                  connect by level <= length(regexp_replace(txt,'[^,]*'))+1
      8*                )
    SQL> /
    Enter value for dept_numbers: 10,20
    old   4:                 with t as (select '&dept_numbers' as txt from dual)
    new   4:                 with t as (select '10,20' as txt from dual)
    
         EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
          7369 SMITH      CLERK           7902 17/12/1980 00:00:00        800                    20
          7566 JONES      MANAGER         7839 02/04/1981 00:00:00       2975                    20
          7782 CLARK      MANAGER         7839 09/06/1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST         7566 19/04/1987 00:00:00       3000                    20
          7839 KING       PRESIDENT            17/11/1981 00:00:00       5000                    10
          7876 ADAMS      CLERK           7788 23/05/1987 00:00:00       1100                    20
          7902 FORD       ANALYST         7566 03/12/1981 00:00:00       3000                    20
          7934 MILLER     CLERK           7782 23/01/1982 00:00:00       1300                    10
    
    8 rows selected.
    

    PL/SQL or, based on the same SQL...

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    cursor cur_emps(p_deptnos in varchar2) is
      3      select *
      4      from emp
      5      where deptno in (
      6                       select REGEXP_SUBSTR (p_deptnos, '[^,]+', 1, level)
      7                       from dual
      8                       connect by level <= length(regexp_replace(p_deptnos,'[^,]*'))+1
      9                      );
     10  begin
     11    for e in cur_emps('10,20')
     12    loop
     13      dbms_output.put_line(e.empno||' - '||e.ename||' : '||e.deptno);
     14    end loop;
     15* end;
    SQL> /
    7369 - SMITH : 20
    7566 - JONES : 20
    7782 - CLARK : 10
    7788 - SCOTT : 20
    7839 - KING : 10
    7876 - ADAMS : 20
    7902 - FORD : 20
    7934 - MILLER : 10
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • Pass the string of subsequence reference to appellant

    Hi, I'm unable to pass a string parameter on the basis of a subsequence to its caller. Is there something by doing this, or is not possible?

    Thank you

    Chris

    Right click on the parameter in the subsequence.

    Make sure you only pass by reference is verified.

  • By passing the string in app.launchURL

    Can Hi I pass a string like that

    var Link_Str = [];

    Link_Str [0] = 'www.' + 'google' + ".com";

    Link_Str [1] = 'www.' + 'yahoo' + ".com";

    Link_Str [2] = 'www.' + 'ebay' + ".com".

    l.setAction ("app.launchURL ('Link_Str [1]", true ")" ");

    error

    Link_Str is not defined

    It should be something like:

    l.setAction ("app.launchURL (\'" + Link_Str [1] + "\", true ")" ");

    You attach this script for what type of object?

  • Pushing data from a Java application * confused *.

    Hello community,

    I'm new to the BlackBerry Push. I tried to understand what options are available to provide data to a Java application and how it can be tested.

    There are so many documents on this subject, for example:

    1. Push for the BlackBerry Enterprise Server software
    2. BlackBerry Push service
    3. Push blackBerry SDK service

    What I discovered thanks to these documents.

    1. There are two formats that can be used to send data through the BES (PAP push / push RIM)
    2. BlackBerry Push service has two levels (BB push Essentials / BB push more - limited to 8 KB content)
    3. In the Push Service SDK, there are two modes available (public and business mode)

    For me, these information are really confusing.

    What I don't understand:

    I. can the software of the BlackBerry Push Service SDK be used for both options 1. & 2. mentioned above? (referring to public and business mode)

    II. is there documentation how to push Service SDK can be configured for the mode of the company?

    III. when you use BES Push is also limited to 8 KB content size?

    IV. is it possible to only a single client application that can be used to BES and BIS push?

    Thanks in advance.

    I. the SDK can be used to push either a BIS or BES. The SDK has a setting to determine if its pressure through the (public) BIS or BES (company). The SDK can be used to push push Essentials or Plush Push. The SDK software uses the API of PAP.

    II. I'm not sure of the documentation, but I don't know that the SDK can ask a BES for sure. But in the end, you need to set the PushSDK.properties flag to push public were false.

    III. no the BES is not a limitation of 8 k.

    IV. I'm not an expert on client applications, but I think you need to develop a version for BIS and a version for BES.

  • By passing the values to and from Excel

    All,

    I'm building a program to collect data of a group of gauge via RS232. One of the requirements of the program is to have the user to tell the program which sample they are on where their samples are not in order. I also need to check my Excel sheet if this sample has already been tested. Some of my code in a module looks like this:

    Function HasSampleBeenTested(dblSample As Double, strSG As String) As Boolean

     

    "Learn if the test sample has been tested.
    HasSampleBeenTested = False
    Range ("B14"). Select

    "First of all, find the number of sample group
    Until ActiveCell.Value = «»
    If ActiveCell.Value = strSG Then
    ActiveCell.Offset (0, - 1). Select
    Exit Do
    On the other
    ActiveCell.Offset (1, 0). Select
    End If
    Loop

     

    "Then look for the real sample.
    Until ActiveCell.Value = «»
    If ActiveCell.Value = ActiveCell.Offset (0, 1) and strSample. Value = strSG Then
    HasSampleBeenTested = True
    Exit Do
    On the other
    ActiveCell.Offset (1, 0). Select
    End If
    Loop

    End Function

     

    I also have a diagram that is connected to this exact instance of Excel, but I'm not sure I know how to wire my type (Boolean) in and out data like a Boolean value by the variation of data VI.

    If the variant data type is a Boolean value, then what you need to do is to wire a Boolean constant (its value is irrelevant) to the variant to the data to convert the variant to a Boolean type.

    : Note "Sample #" and "Previous Sample" supposed to be integer values? If so, you should do the data instead of DBL I32 type. If the value is really floating point, then you should NOT use a function equal to compare floats. Do a search on this topic (by comparing the floats).

    In addition, no particular reason why you use a local variable to 'Raw Data Report' instead of a thread?

  • Pass the 32-bit client from host 32-bit to 64-bit host

    Hello

    I created a client of Windows 2003 32 bit on Win XP 32 bit host server using vmware workstation 6.0.3

    Now, I need to use this vmware image on a host of Win XP 64 bit or Vista 64-bit. Does anyone know if there could be complications with that?

    Thank you!

    None

    you just need to copy and paste your VM and make sure that you have a sufficient resources for your virtual machine (with Vista, you lose some of them)

    concerning

    Jose Ruelas B

    http://aservir.WordPress.com/

  • use java edition and edition of native at the same time in a single java application

    Hello

    I have a situation where I need to use both versions of berkeley Db at the same time. I have an external library that I use and which requires the Java edition and my own code which uses the native version. Unfortunately, the library source code is not available and I don't want to see my program to use the Java edition.

    Some packages in je.4.0.103.jar and db.jar (version 5.1) contain the same naming structure and classes for example. com.sleepycat.persist.EntityStore. I removed the packages duplicated in je.4.0.103.jar however, it seems that the implementation is slightly different between the two versions I get

    java.lang.NoSuchMethodError: com.sleepycat.persist.EntityStore. < init > (MBCA/sleepycat/I/environment; Ljava/lang/String; MBCA/sleepycat/persist/StoreConfig ;) V

    When I had just two available versions my code for the preserved native version using the packets from the Java edition and an external library maintained on the use of the native version and therefore I had loads of errors.

    So how I differentiate them. The problem is because the two sets of packages have identical names and the names of classes for Java does not know which ones to use. I use eclipse then maybe there is an option where I can say that some classes to use some packages.


    Any ideas?

    Hello

    We do not officially support using BDB and BDB I from the same JVM process.

    It is possible to circumvent this limitation by creating two [url http://download.oracle.com/javase/1.4.2/docs/api/java/lang/ClassLoader.html] Chargers of Java classes which load a file two jar. When you call BDB or BDB I methods, the call should be put in brackets with calls like this that cause the correct class loader to use:

    ClassLoader saveLoader = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(/* specify correct loader for BDB or BDB JE here */);
    try {
       // do something with BDB or BDB JE
    } finally {
      Thread.currentThread().setContextClassLoader(saveLoader);
    }
    

    We are not experts in the field of chargers for custom classes and we do not have an example of this. We don't him did not ourselves, we know only that users have done.

    I hope this helps.

    Kind regards
    Alex Gorrod
    Oracle Berkeley DB

  • Displacement of the unit number logic from one ESX host to another

    I am a newbies VI3. Are there opportunities to move a unit logic of an ESX host number to another?

    I can't find any guide. Help, please.

    Thank you.

    You don't need to remove the LUN from the host of the first.

    It is enough to present the second ESX host storage, don't know how you do it for the EMC storage.

    If you have virtual center then you just select the host, go to Setup and select storage adapters and then rescan the HBAs. This storage should appear.

    If you do not have virtual Center, then you should be able to do it from the host.

    The main thing to make sure, it is that you present the LUN with the same ID for all guests.

    If you really need to delete a logical unit number not used, check that no virtual machines are using, use the management of storage to anyone there and then rescan the HBAs as above.

  • Question about the displacement of vCenter from one physical server to another

    Here's the scenario:

    We currently have vCenter 2.5 installed on a windows XP machine. He manages 3 ESX hosts in a HA cluster.  I built a new server with windows 2008 x 64 and installed vCenter 4.0 by using a copy of our vCenter SQL database. Everything is going well so far, but now I have to say the 3 hosts where is the new vCenter. I have the procedure to change the ip address of the host. What I was wondering is when I go to the first host and change the ip address on the new server, the old server will be missing a single host. He will not try to turn on the virtual machine that were on this host on the other 2 immediately? Same thing on the other end. Once vCenter 4.0 has an added guest, won't he try and turn all the vm on it due to HA? Can I avoid this simply by stopping the service of vCenter on both servers before trying the switch?

    your virtual machine will be fine.  Everything you do is update vCenter management agents.  For example, you could simply make a disconnection and connection and information will fill as well.

  • Connect the oscilloscope Tektronix TDS5054 from a LabView application



  • Structure from case string "&lt;------"-LabVIEW converts the string

    Hello

    I want to parse the string lines read from a data file.  Some chains start with the characters ".<\".  when="" i="" enter="" this="" kind="" of="" string="" as="" a="" case="" in="" a="" case="" structure="" the="" string="" is="" being="">

    For example, I'm going home. "<\C" (upper-case="" c)="" as="" my="" case="" string,="" it="" changes="" to=""><\f".  if="" i="" enter=""><\c" (lower-case="" c)="" as="" the="" string="" it="" becomes="">

    I am currently using LabVIEW 2012.

    Any ideas what's happening?

    Thank you

    Ian

    Some ASCII characters are nonprinting control characters (less than 32 values). These are sometimes encoded using the backslash code and it seems that is what makes the structure of matter - when you type \C, the structure of the performer as "oh, you want the value 0x0C ASCII, which in the code for backslash is represented" as \f (means 'form feed). "When this is the case, you typically use one-to represent the------characters, so you really need set the structure to match on.<>

  • Pass dynamic strings to procedure

    Oracle 11g r2 and Java

    Oracle procedure:

    procedure sp_get_account)

    p_rc on sys_refcursor,

    p_state varchar2

    )

    Open the p_rc for

    Select *.

    of user_table

    where to report in (p_state);

    Example of HARD CODE: select * from user_table where State in ("NY", "FL", "MY");

    Now, I want to dynamically pass the string on the java side: call.setString (2, stateStr);

    I am now tring stateStr = "'NY', 'FL', 'MY" ";    Does not work.

    How the stateStr should be built?

    Thank you

    Scott

    Or you can try this:

    (Sp_get_account) CREATE or REPLACE procedure

    p_rc on sys_refcursor,

    p_state varchar2

    )

    as

    Start

    Open p_rc for ' select * from user_table where State in ('|) REGEXP_REPLACE (p_state,'([A-Z]+) ', "'\1"') |') ' ;

    end;

    /

    Pass p_state as in format NY, FL, MY:

    EXEC sp_get_account(:p_result,'NY,FL,MA');

    Take care of sql injection.

  • Unable to capture the String [] to a JavaCallOut

    Hi all

    I am applying where I have to make a legend of java that accepts the string and returns an array of strings as output. "The only java class works well but when I do the legend of Java and pass the string I get *" < con: java-Ref content = "jcid:-31630335:136f3572827:-3925 ' xmlns:con ="http://www.bea.com/wli/sb/context"/ >" * as a response. " How can I access the variable table in OSB?

    Kindly help me in this.

    Concerning
    Flavian.

    in the legends of Java, I would avoid types that are not in THE list of supported types:

    http://docs.Oracle.com/CD/E13159_01/OSB/docs10gr3/eclipsehelp/ui_ref.html#wp1290279

    java.lang.String [] is supported for the ENTRY ONLY

    Simply return some CSV in a string and you will be happy
    or return an XmlObject containing several elements

    A con: java-thingie content can be dealt with in another legend of Java only rather than a stream of messages of OSB...

Maybe you are looking for

  • The Sims 3 - no newspaper accident or mistake.

    Hello! Well, my problem is with the Sims 3. I can play the game for the first 5 minutes fine, but then it will randomly be out bug. The game will close and open and eventually gets stuck on a black screen. Because it freezes I have to force my laptop

  • on the voice control

    I noticed that if your not connected to the internet the voice command does not work... is it really need that your phone must be connected to internet to be able to work the voice command?

  • Questions classic blackBerry Blackberry Classic compared to the features and functions of the Bold 9900

    I am extremely satisfied with the functionality of my Blackberry Bold 9900 and yet I am fun the idea of upgrading to a classic Blackberry and had a few questions, some of them functional, but one of them is technical: (1) I have granularily configure

  • ACS 5.4 failure after installing Patch - 5-4-0-46-4

    I installed the last path (5-4-0-46-4) on ACS server and after that I'm getting following error when I try to access System Administration > ... > Administrators > Administrative access control > Authorization The error message is This failure has oc

  • D5500 HAS BEEN ADDED

    My printer prints lines and columns of zeros 00000000 at the bottom of the page. What should I do to get rid of it