Opening another java class from a class itself?

I want to run a java program(lets call it preInput.java) that has a bunch of inputs and some buttons, and on one of these buttons I click, it opens a driver program that uses the input from preInput.java. Is this possible? Thanks for the help

I'm afraid it's not very clear to me, but I'll try to give you what I think might be a possible answer.
(in preInput.java)
button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        Vector params = new Vector();
        params.add(...);       // adding all of the parameter values here
        ** provided that your new executed program has a suitable constructor and is able to parse
        ** the passed parameter vector
        NewProgram program = new NewProgram(params);
});I hope this will help (of course if I haven't missed the point!).
Bye

Similar Messages

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • Calling another java class from a java class

    Hi Friends,
    I have a class tht works in 2 modes,depending upon which mode i am passing (gui or text) on the command line eg:
    java myclass [mode]
    I want to call this command from another java class,and i wrote this code:
    try
             Process theProcess =
                Runtime.getRuntime().exec("java myclass  "+args[0]);
          catch(IOException e)
             System.err.println("Error on exec() method");
             e.printStackTrace();
          }When i pass "gui" it works fine,but when i pass"text", the class completes and nothing shows up on the command prompt window,so can please somebody tell me how to make this work.
    Thanks

    As aniseed just pointed out, you could do something like this:
    import javax.swing.*;
    class Test extends JFrame {
         public Test(String title) {
              this.setTitle(title);
              this.pack();
              this.setSize(300, 300);
              this.setLocationRelativeTo(null);
              this.setDefaultCloseOperation(EXIT_ON_CLOSE);
         public static void main(String[] argv) { new Test(argv[0]).setVisible(true); }
    public class Test2 {
         public static void main(String[] argv) {
              Test.main(argv);
    }Run it by executing this command:
    java Test2 "Title of Frame"See if that's not what you're looking for ...

  • Legalities of modifying open source Java classes in a closed source App

    If there is a better forum for this thread please let me know. I looked and looked and couldn't find any place where it seemed to fit.
    Simply put, I want to know the legal ramifications of modifying open source Java classes which have been included in a commercial closed source application.
    The specifics are my problem with the javax.servlet.http.Cookie classes interpretation with RFC 2019 in regards to acceptable cookie names. I currently am debating that in a thread here:
    http://forums.sun.com/thread.jspa?threadID=5313146
    I am using Adobe ColdFusion which is a J2EE application server running as a servlet in Macromedia JRun. JRun parses request headers and creates instances of the javax.servlet.http.Cookie class for each cookie. (An error is thrown from the constructor if the cookie name is not accepted)
    I was able to work around the problem by modifying the code in the Cookie class, compiling it, and using jar.exe util in my SDK to update the new class into the jrun.jar file. I blogged it here:
    http://www.codersrevolution.com/index.cfm/2008/7/15/No-Cookie-For-You-Second-Solution
    My problem is I'm not sure if what I did conforms to the license for ColdFusion. Technically JRun is a closed source program I am not allowed to modify, but all I changed was a open source class from Sun. I didn't even need to decompile anything.
    I have Googled in vain, but I can't seem to find any information that applies to modifying pieces of open sourced code contained inside of a closed source application.

    bdw429s wrote:
    "I thought it was straightforward and I didn't feel that lawyers were necessary. But you didn't seem to want to do that."
    I'm unclear on whether you are implying that I didn't want to hire a lawyer or that I didn't want to read the licenses myself and make a decision. If you meant the former, you're darn right. I'm not paying anyone a dime to satisfy my personal acedemic curiosity concerning a random project I've been messing with in my spare time that isn't related to to any job or business decision. I'm simply looking for information because that's I do when I don't understand how something works. First, I Google the hell out of it and if I can't turn up satisfactory answers (or any at all) I find an applicable forum and ask there.
    If you were implying the latter (that I didn't want to read the licenses myself) then you haven't been reading my posts. I stated to jschell that I have no problem attempting to figure out a license agreement on my own. In fact, I have read the ColdFusion agreement from Adobe before posting here. I talks about modifying the software, but I still don't think it is crystal clear about whether third part code falls under it's own license AND Adobie's or just its own license. Then that is the point at which you must do one of the following
    1. Consult a lawyer.
    2. Decide to allow for a liberal interpretation (thus you can use the code) and understand that you personally are liable if your interpretation is wrong.
    3. Decide to allow for a conservative intepretation to avoid liable on your part.
    Regardless of what anyone says here it won't remove your own liability.
    >
    The source for the java.servlet.http.Cookie class stated that it is release under the Apache license 2.0 whcih I read up on. I will admit I'm not actually sure how to tell the exact verison of the Java Servlet API classes that JRun is built on other than to cross reference which version of the servlet API came out with which version of Java, but that is a suspect method. I have been programming for more than 8 years, but I'm relatively new to the Java landscape.
    I'm not looking for handouts here. I know this was a tough subject and I was prepared for NO ONE to respond and I would have been ok with that. I have no problems making decisions on my own and I have no intention of passing the buck to anybody.
    Here's the thing though. A useful response is one that states some facts (or opinions), references a similar peice of software for comparison, a court case, or provides a few links to some open source-type websites were I might find more information about my issue.
    Telling me to hire a lawyer and chastising me for "pass the buck" is doing about as much good as Linux snobs telling people to RTFM.
    Wrong.
    A lawyer is the best and most correct answer.
    And it is the first answer that should always be given with these sorts of questions.
    If you choose not to accept the best and most correct answer then that is up to you.
    I understand that a large number of people on public forums are lazy sponges who wish someone would just post all the code they need, but assure you I am not that person. I'll admit I don't know much about open source and I'm not sure where to start looking since I seem to have a scenario which is not really discussed much on the web. All I am looking for is information and sincere help.And presumably you also understand that we certainly can't give you legal advice but also it would be foolhardy for you to accept it as well.
    You learn by reading many license agreements and reading as much about legal situations involving computers and related technical cases as you can.
    And until you are comfortable making such decisions yourself without asking then the only useful answer is ask a lawyer.

  • Open a java file from c#

    Does anyone know if it's possible to open a java file from a c# web form?
    Any links would also be appreciated,
    Thanks,
    Clivert

    I don't know anything about C# web forms (that's pretty far away from the topic of this forum) but I expect anybody answering the question would need to know what you mean by "open" and "a java file" in that context.
    For example it might mean to cause a text editor to run and display the source code for a Java class. Or it might mean for a Java JVM to start running and execute the main method of a Java class.

  • Can we run EXE file/ Another Java Program from Java Application? How?

    Can we run EXE file and another java program from java application?
    Thanks in advance

    Example running adobe acrobat
    String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
    Runtime rn = Runtime.getRuntime();
    Process process = rn.exec(command);
    process.waitFor();rykk

  • How to open a java application from a web page?

    Friends
    I am in a situation to open a java application from a web page. I wrote a applet and placed a button on it. Onclicking of that button i con't open my java application. plz help me to open a userdefined application from web page.
    Ramesh
    e-Brahma technologies

    http://java.sun.com/products/javawebstart/index.jsp

  • Calling another java class from a servlet

    I am trying to write a web based form handling system (for a college project)
    I have a servlet that responds to a user request for a form. I have another java program (HTMOut) that parses the xml file for the form and produces HTML output. When I call the HTMOut from the servlet it crashes the webserver (Tomcat). But if I call HTMOut from an ordinary java class it runs fine. If I call another test program from my servlet that works too.
    Any ideas?

    where does your HTMOut output? A file or a stream? I think it is better that HTMOut can output to a stream you can set externally.

  • How to get properties of a bean from another java class

    Hi,
    I am new to JSF. Currently I am facing a problem, and hope you experts can give me some guidance.
    The JSF app i am working on has one Java class for handling a tree structure, MyTreeNode.java, and it also has a bean, NameBean.java, which has two properties, username and password.
    I can easily associate an input text with the #{name.username} to store the user's login... but later on, I need to fetch that information inside of MyTreeNode.java. How do I do that? Thanks!
    -- Jim

    <managed-bean>
         <managed-bean-name>Person</managed-bean-name>
         <managed-bean-class>demo.PersonBean</managed-bean-class>
         <managed-bean-scope>session</managed-bean-scope>
         <managed-property>
              <property-name>bank</property-name>
              <property-class>demo.BankBean</property-class>
              <value>#{bank}</value>
         </managed-property>
    <managed-bean>
    <managed-bean>
         <managed-bean-name>bank</managed-bean-name>
         <managed-bean-class>demo.BankBean</managed-bean-class>
         <managed-bean-scope>session</managed-bean-scope>
    <managed-bean>this version doesnt work for me.
    does the single beans have to look any special?
    some demo code out there?
    thx!

  • How do you run another Java file from a master Java file?

    We're making a game in Java at school, and we need to know how we can run a Java file from another one - like inside the master Java file, we need to have a command to run game.java (something like that). Thanks!

    We're making a game in Java at school, and we need to know how we can run a Java file from another one - like inside the master Java file, we need to have a command to run game.java (something like that). Thanks!One doesn't "run a Java file", and there's no conventional definition of "master Java file". If you want to call the main() method of another class, just make sure the class is in your classpath and call the method. If you want to start up a separate JVM with that class as a process, use Runtime.exec() or similar method.
    ~

  • When clicked on an icon in the infopath form, it will open another infopath form from another file. How do?

    When clicked on an icon in the infopath 2013 form, it will open another infopath 2013 form from another
    file. How do?

    Hello Eugene Astafiev!
    I need the following scenario: 
    I have a Sharepoint library with items created by Infopath (form A). 
    I developed another form (form B) that will query items created by form A. 
    The form B will be in a static "webpart" page navigation (Sharepoint). One of these fields returned by the query library that manages the items created is the URL responsible to load the item data . I would like to parameterize the URL into form B.
    So that when the user clicks on it, the form A with their respective data in a modal is returned (which may be a native modal Sharepoint)

  • Opening a java application from a java application

    I am trying to write a simple patching application for a program I am writing. The application must work on both Windows and Mac computers. The program is compiled into a single jar file. To patch the program, I'd like to see if an update is available, download the update if it's available and if the user requests it, and then apply the patch. Since this is a very simple, relatively small program, the "patch" is actually just a newer version of the jar file.
    I've haven't had any problems in detecting or downloading the updated jar file. The problem I'm having is that I can't overwrite the old jar file with the new one while the program is running (of course). Therefore, I wrote a separate patch program that does the actual downloading and replacing work. The order of operations should look like this:
    Open program -> Check for patch -> If user wants to patch then...
    Open patch application -> Close program -> Patch application downloads new jar file and replaces old jar file -> Open original program -> Close patch application.
    However, I can't seem to open the patch application from the original application. I'm using Runtime.getRuntime().exec("java -jar patchApp.jar") but I'm not getting any output whatsoever, neither the program running nor an exception. Can anyone suggest something here? Any help is appreciated.

    However, I can't seem to open the patch application
    from the original application. I'm using
    Runtime.getRuntime().exec("java -jar patchApp.jar")
    but I'm not getting any output whatsoever, neither the
    program running nor an exception. Can anyone suggest
    something here? Any help is appreciated.I've had bad results using the Runtime.exec method. It doesn't seem to be very reliable, at least not in Windows (that's probably not Java's fault.)
    Can you run java by just typing java at the console or do it have to be qualified. Make sure your patchApp.jar argument is in the correct case also.
    I gave up on exec and use JNI to delegate this task to native code. That's going to a little more complicated if you are running in two environemts.

  • Running another java prog from a java program

    hi,
    I would like to add a button to my program in which when pressed, it will launch another java program.
    so far i googled and found out how to run from this site:
    http://www.devx.com/tips/Tip/13867
    but when the 2nd program is launched, the first program become inaccessible until the 2nd program is terminated.
    is there any way to run the program without causing the first program inaccesible? thank you

    run the commands in seperate threads.
    http://java.sun.com/docs/books/tutorial/essential/threads/

  • How can we call one java class in another java class?

    Hi all,
    My problem is ,
    one java code creates a file i have to send that file through email as an attachment here i wrote a java code to send a mail with attachment
    can any one help me how i can implement this. my idea is to write a send mail function in 1st java code which creates the file
    Is this a better idea ???plz suggest me.

    Hi all,
    My problem is ,
    one java code creates a file i have to send that file
    through email as an attachment here i wrote a java
    code to send a mail with attachment
    can any one help me how i can implement this. my idea
    is to write a send mail function in 1st java code
    which creates the file
    Is this a better idea ???plz suggest me.may samaaj nahi atay

  • How to Open another jsp page from jsp page

    Hi,
    I am new to JSP. I need help to handle issue given below:
    I have created one JSP Page for Login which contains Username and Password with a Submit Button. Once user inputs UserName and Password and Press Submit Button, It calls another JSP Page "Validate_login"
    Validate_Login JSP does a JDBC call to Databse and validate User Name and Password. Now i want to open a "Employee.jsp" page if Username and Password matches with the one in database.
    Pls advice what function or tag should i use to open this page in If (condition) true section.. I tried Window.open but it return back with error.

    I tried with the function suggested by Doly. But nothing is happening. It doesn't redirect to any page. only a blank page comes.
    here is complete code . pls correct me if i am wrong somewhere.
    this is code of Validate_Login.jsp page which is invoked when user press login button on login.jsp.
    my purpose is to validate username and password from database and redirect to employee.jsp if it is ok else back to login.jsp
    here is source of Validate_login.jsp
    =============================================================
    <%@ page language="java" import="java.sql.*" pageEncoding="ISO-8859-1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Validate Login</title>
    </head>
    <body>
    <%
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String viewPATH = "c:/MyData.mdb";
    String dsnPATH = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb); " +
    "DBQ="+viewPATH+"; " +
    "UserCommitSync=Yes; " +
    "Threads=3; " +
    "SafeTransactions=0; " +
    "PageTimeout=5; " +
    "MaxScanRows=8; " +
    "MaxBufferSize=2048; " +
    "DriverId=281; " +
    "DefaultDir=C:/ProgramFiles/CommonFiles/ODBC/DataSources";
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         conn = DriverManager.getConnection(dsnPATH, "", "");
         stmt = conn.createStatement();
    rs= stmt.executeQuery("SELECT * FROM Employee where emp_id='"+username+"'");
    while(rs.next())
    String pass = rs.getString("password");
    if (pass.equals(password))
    { response.sendRedirect("Employee.jsp");}
    else
    { response.sendRedirect("login.jsp");}
    catch(Exception e)
    e.printStackTrace();
    finally
         if(stmt!=null) stmt.close();
         if(conn!=null) conn.close();
    %>
    </body>
    </html>

Maybe you are looking for