Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 29720 invoked from network); 4 Feb 2004 17:26:19 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Feb 2004 17:26:19 -0000 Received: (qmail 51007 invoked by uid 500); 4 Feb 2004 17:25:49 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 50959 invoked by uid 500); 4 Feb 2004 17:25:48 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 50930 invoked from network); 4 Feb 2004 17:25:48 -0000 Received: from unknown (HELO web20304.mail.yahoo.com) (216.136.226.85) by daedalus.apache.org with SMTP; 4 Feb 2004 17:25:48 -0000 Message-ID: <20040204172551.42684.qmail@web20304.mail.yahoo.com> Received: from [153.2.246.12] by web20304.mail.yahoo.com via HTTP; Wed, 04 Feb 2004 09:25:51 PST Date: Wed, 4 Feb 2004 09:25:51 -0800 (PST) From: Shailesh Sharma Subject: RE: Newbie; how to invoke an ant script from a GUI interface To: Ant Users List In-Reply-To: <42C9EFEA1737D511BA420008C78641510CA49835@ncwlmx01nege.wilm.ge.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-2098903775-1075915551=:42613" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --0-2098903775-1075915551=:42613 Content-Type: text/plain; charset=us-ascii HI Luis, Iam still wondering if you can help me in writing a simple JSP that invokes my ANT targets. This is how my build.xml file looks like and it has got 3 targets. I can run these ANT targets by typing in UNIX box>ant deploy-ias-testnet and it works !!!!! thanks for your help on that last time. But i wanted wrap these ANT targets with a simple JSP page which displays my 3 targets and when i select the first target and then hit "enter" it basically invokes the selected and the corresponding ANT target. Please help me !!! -shailesh "Conelly, Luis (PS, GNF, Contractor)" wrote: >From a non-Grapical session, yes (well there are several other ways to access the graphical environment in Unix boxes; Exceed is the one I recommend because I have successfully used, from a windows workstation) Try to write a JSP file that executes just the runAnt() method and the OutputStream must be de default output for your JSP file. Let me see if I can find some time to do this. Regards Luis G Conelly Mobile (449)123-8749 There are 10 kinds of programmers: * Those who know binary code * Those who does not -----Original Message----- From: Shailesh Sharma [mailto:shailesh_scea@yahoo.com] Sent: Friday, January 16, 2004 9:04 AM To: Ant Users List Subject: RE: Newbie; how to invoke an ant script from a GUI interface ohhh ok. So i need to install Exceed and configure it .........correct ? This is the only way to access this Applet (on unix). -shailesh "Conelly, Luis (PS, GNF, Contractor)" wrote: mmmm.... sounds like you do not have any GUI interface (such an XWindow or something like that). I have tried to use this applet in Unix (Sun Sparc 5.8) but I used Exceed client[1] to connect from my windows workstation, and it worked fine. If you are trying to execute the applet from a simple telnet console (such as windows telnet client) you will not be able to execute it, since that kind of client does not have the ability to load / execute Graphic Environment Regards [http://www.hummingbird.com/products/nc/exceed/index.html] -----Original Message----- From: Shailesh Sharma [mailto:shailesh_scea@yahoo.com] Sent: Thursday, January 15, 2004 2:11 PM To: Ant Users List Subject: RE: Newbie; how to invoke an ant script from a GUI interface Thanks Luis, Now the applet works. But it works only on Windows machine. When i migrated this Applet to a unix box, this is what iam getting. Please Note that the Applet compiled succesfully on unix box too but it is only when iam trying to run this applet that the applet is failing. This is the error iam getting when running this applet on unix box: root@reliant2# java -classpath /opt/bea/jdk141_03/jre/lib/rt.jar:/opt/bea/weblogic81/server/lib/ant/ant.jar: org.apache.tools.ant.antgui.TestApplet Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable. at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:59) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58) at java.awt.Window.(Window.java:188) at java.awt.Frame.(Frame.java:315) at java.awt.Frame.(Frame.java:262) at org.apache.tools.ant.antgui.TestApplet.main(TestApplet.java:98) any ideas or solution is higly appreciated. thanks, shailesh "Conelly, Luis (PS, GNF, Contractor)" wrote: you might want to create a separated project and create the full to run this class; i.e. \org\apache\tools\ant\antgui | |----> TestApplet.java Then, compile the class like: \org\apache\tools\ant\antgui> javac -classpath %JAVA_HOME%\jre\lib\rt.jar;%ANT_HOME%\lib\ant.jar TestApplet.java Finally, execute your class like java -cp %JAVA_HOME%\jre\lib\rt.jar;%ANT_HOME%\lib\ant.jar;. org.apache.tools.ant.antgui.TestApplet You must be able to see the applet and execute it. Regards -----Original Message----- From: Shailesh Sharma [mailto:shailesh_scea@yahoo.com] Sent: Thursday, January 15, 2004 11:59 AM To: Ant Users List Subject: RE: Newbie; how to invoke an ant script from a GUI interface iam confused. This is where i originally kept this class: C:\bea\wlserver6.1\config\beaMonitor\applications\JMXStatistics\WEB-INF\classes\parsing And hence i put: package parsing; on top of this class. But you are saying that i need to put this package name as package org.apache.tools.ant.antgui; instead of package parsing; Then when iam putting the package name as you suggested then iam getting this error: This package doesnot correspond to the file path 'parsing' do i need to create this class somewhere else i.e where the ANT is installed or where ??? please suggest. "Conelly, Luis (PS, GNF, Contractor)" wrote: Shailesh, If you remember, in the class I sent, I declared the package as: package org.apache.tools.ant.antgui; but you declared the package as: package parsing; I've been looking around the source code (ant 1.6) and I found that the setProject(Project) method is public, but just in the abstract class org.apache.tools.ant.ProjectComponent, which inherits to org.apache.tools.ant.Task and this inherits to org.apache.tools.ant.taskdefs.ExecTask. When you are trying to access to this method from an outside package the compiler does not allows you, since the method is not explicitely declared in Task or ExecTask classes. My suggestion: change the package name -------------- [1] http://www.site.uottawa.ca:4321/oose/index.html#protectedmethod [2] http://gcc.gnu.org/ml/java-prs/2000-q2/msg00238.html [3] http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#62587 -----Original Message----- From: Shailesh Sharma [mailto:shailesh_scea@yahoo.com] Sent: Thursday, January 15, 2004 9:58 AM To: Ant Users List Subject: RE: Newbie; how to invoke an ant script from a GUI interface Luis, I have made the required changes as you directed but while compiling iam getting this error: setProject(org.apache.tools.ant.Project) is not public in org.apache.tools.ant.Task; cannot be accesed from outside package what is this problem and how can i solve it. This is how my class looks like: package parsing; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.net.URL; import org.apache.tools.ant.BuildLogger; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.ExecTask; import org.apache.tools.ant.types.Commandline; //import com.borland.jbcl.layout.*; public class TestApplet extends Applet { private boolean isStandalone = false; TextArea textArea1 = new TextArea(); BorderLayout borderLayout1 = new BorderLayout(); Panel panel1 = new Panel(); BorderLayout borderLayout2 = new BorderLayout(); Button button1 = new Button(); Button button2 = new Button(); //Get a parameter value public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } //Construct the applet public TestApplet() { } //Initialize the applet public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { this.setLayout(borderLayout1); textArea1.setEditable(false); textArea1.setText(""); this.setVisible(true); panel1.setForeground(Color.black); panel1.setLayout(borderLayout2); button1.setLabel("Execute"); button1.addActionListener(new TestApplet_button1_actionAdapter(this)); button1.addActionListener(new TestApplet_button1_actionAdapter(this)); button2.setLabel("Exit"); button2.addActionListener(new TestApplet_button2_actionAdapter(this)); this.add(textArea1, BorderLayout.CENTER); this.add(panel1, BorderLayout.SOUTH); panel1.add(button1, BorderLayout.WEST); panel1.add(button2, BorderLayout.EAST); } //Get Applet information public String getAppletInfo() { return "Applet Information"; } //Get parameter info public String[][] getParameterInfo() { return null; } public void runAnt() { PrintStream ps = new PrintStream(new TaOutputStream()); Project project = new Project(); BuildLogger logger = new DefaultLogger(); logger.setMessageOutputLevel(Project.MSG_INFO); logger.setOutputPrintStream(ps); logger.setErrorPrintStream(ps); logger.setEmacsMode(true); project.addBuildListener(logger); ExecTask exec = new ExecTask(); exec.setProject(project); exec.setExecutable("C:/bea8.1/weblogic81/server/bin/ant.bat"); exec.setDir(new java.io.File("c:/shailesh")); Commandline.Argument arg = exec.createArg(); arg.setLine("-buildfile c:/shailesh/build.xml"); exec.execute(); ps.flush(); } //Main method public static void main(String[] args) { TestApplet applet = new TestApplet(); applet.isStandalone = true; Frame frame; frame = new Frame(); frame.setTitle("Applet Frame"); frame.add(applet, BorderLayout.CENTER); applet.init(); applet.start(); frame.setSize(400,320); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); frame.setVisible(true); } void button1_actionPerformed(ActionEvent e) { runAnt(); } class TaOutputStream extends OutputStream { TaOutputStream() { super(); } public void write(int b) throws IOException { byte[] bytes = new byte[] {(byte) b}; String out = new String(bytes); textArea1.append(out); } public void write(byte[] b, int off, int len) throws IOException { String out = new String(b, off, len); textArea1.append(out); } } void button2_actionPerformed(ActionEvent e) { System.exit(0); } } class TestApplet_button2_actionAdapter implements java.awt.event.ActionListener { TestApplet adaptee; TestApplet_button2_actionAdapter(TestApplet adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.button2_actionPerformed(e); } } class TestApplet_button1_actionAdapter implements java.awt.event.ActionListener { TestApplet adaptee; TestApplet_button1_actionAdapter(TestApplet adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.button1_actionPerformed(e); } } please advise....thx, shailesh "Conelly, Luis (PS, GNF, Contractor)" wrote: shailesh Remove that line. I accidentally left it but it is not usefull at all. BTW, make sure you are setting the right paths for the lines: ----------------------------------------- exec.setExecutable("/bin/ant.bat"); exec.setDir(new java.io.File("")); Commandline.Argument arg = exec.createArg(); arg.setLine("-buildfile /build.xml "); ----------------------------------------- Regards. Luis -----Original Message----- From: Shailesh Sharma [mailto:shailesh_scea@yahoo.com] Sent: Thursday, January 15, 2004 8:47 AM To: Ant Users List Subject: RE: Newbie; how to invoke an ant script from a GUI interface Luis, Iam using WLS 8.1 and iam using the ANT that comes along with it. The example that you gave me doesn't seems to work for me as i doesn't have the package called: import com.borland.jbcl.layout.*; what should i do ? And i have set the classpath as: c:\bea8.1\weblogic8.1\server\lib\ant\ant.jar Please help. -shailesh "Conelly, Luis (PS, GNF, Contractor)" wrote: Shalesh I have tested following class. It is trully rudimentary, but it is a good place to start: -------------------- package org.apache.tools.ant.antgui; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import java.net.URL; import org.apache.tools.ant.BuildLogger; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.ExecTask; import org.apache.tools.ant.types.Commandline; import com.borland.jbcl.layout.*; public class TestApplet extends Applet { private boolean isStandalone = false; TextArea textArea1 = new TextArea(); BorderLayout borderLayout1 = new BorderLayout(); Panel panel1 = new Panel(); BorderLayout borderLayout2 = new BorderLayout(); Button button1 = new Button(); Button button2 = new Button(); //Get a parameter value public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } //Construct the applet public TestApplet() { } //Initialize the applet public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { this.setLayout(borderLayout1); textArea1.setEditable(false); textArea1.setText(""); this.setVisible(true); panel1.setForeground(Color.black); panel1.setLayout(borderLayout2); button1.setLabel("Execute"); button1.addActionListener(new TestApplet_button1_actionAdapter(this)); button1.addActionListener(new TestApplet_button1_actionAdapter(this)); button2.setLabel("Exit"); button2.addActionListener(new TestApplet_button2_actionAdapter(this)); this.add(textArea1, BorderLayout.CENTER); this.add(panel1, BorderLayout.SOUTH); panel1.add(button1, BorderLayout.WEST); panel1.add(button2, BorderLayout.EAST); } //Get Applet information public String getAppletInfo() { return "Applet Information"; } //Get parameter info public String[][] getParameterInfo() { return null; } public void runAnt() { PrintStream ps = new PrintStream(new TaOutputStream()); Project project = new Project(); BuildLogger logger = new DefaultLogger(); logger.setMessageOutputLevel(Project.MSG_INFO); logger.setOutputPrintStream(ps); logger.setErrorPrintStream(ps); logger.setEmacsMode(true); project.addBuildListener(logger); ExecTask exec = new ExecTask(); exec.setProject(project); exec.setExecutable("/bin/ant.bat"); exec.setDir(new java.io.File(" ")); Commandline.Argument arg = exec.createArg(); arg.setLine("-buildfile /build.xml "); exec.execute(); ps.flush(); } //Main method public static void main(String[] args) { TestApplet applet = new TestApplet(); applet.isStandalone = true; Frame frame; frame = new Frame(); frame.setTitle("Applet Frame"); frame.add(applet, BorderLayout.CENTER); applet.init(); applet.start(); frame.setSize(400,320); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); frame.setVisible(true); } void button1_actionPerformed(ActionEvent e) { runAnt(); } class TaOutputStream extends OutputStream { TaOutputStream() { super(); } public void write(int b) throws IOException { byte[] bytes = new byte[] {(byte) b}; String out = new String(bytes); textArea1.append(out); } public void write(byte[] b, int off, int len) throws IOException { String out = new String(b, off, len); textArea1.append(out); } } void button2_actionPerformed(ActionEvent e) { System.exit(0); } } class TestApplet_button2_actionAdapter implements java.awt.event.ActionListener { TestApplet adaptee; TestApplet_button2_actionAdapter(TestApplet adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.button2_actionPerformed(e); } } class TestApplet_button1_actionAdapter implements java.awt.event.ActionListener { TestApplet adaptee; TestApplet_button1_actionAdapter(TestApplet adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.button1_actionPerformed(e); } } -------------------- Of course you need the ant.jar file in your classpath to execute this class. It can be executed as stand alone or in a web browser... HTH Luis --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes --------------------------------- Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! --0-2098903775-1075915551=:42613--