You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by dr_pompeii <dr...@yahoo.com> on 2009/09/18 19:30:26 UTC

How To: Java Command to Ant

Dear Members

I have this java comand (related with JMX)

java -classpath D:\TR\...a.jar;D:\TR\b.jar; -Dcom.sun.management.jmxremote
com.jordan.Main	

This work, then I can get a connection from jconsole (PID from Local Tab
Pane)

The point is that is a long classpath and work for windows, therefore this
in Linux is heavy to be changed, 
I used to work with ant (I am not an expert), usually with this is enough

<target name="run">				 
        <java fork="true" classname="com.jordan.Main"
classpathref="libraries">
            <classpath path="${bindir}"/>          
        </java>
</target>	 

The code work, but I can never get a connection from jconsole because never
appear any PID

Therefore I need your knowledge, what is misssing in my ant configuration

Thanks in advanced
-- 
View this message in context: http://www.nabble.com/How-To%3A-Java-Command-to-Ant-tp25512317p25512317.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How To: Java Command to Ant

Posted by dr_pompeii <dr...@yahoo.com>.
Hello Francis

Thanks a lot, I have already resolved this by other friend, your approach is
practically the same

Thanks!

-Manuel


Francis Galiegue-4 wrote:
> 
> On Mon, Sep 21, 2009 at 02:34, dr_pompeii <dr...@yahoo.com> wrote:
>>
>> Hello supareno
>>
>> Thanks for the reply, but no woek :-(
>>
> 
> Try this:
> 
> <path id="myclasspath">
>     <!-- fill with whatever is necessary -->
> 
> <java fork="true" classname="com.jordan.Main" failonerror="true">
>     <jvmarg value="-Dcom.sun.management.remote"/>
>     <!-- Necessary nested <arg> elements here, but it looks like there
> aren't any -->
>     <classpath refid="myclasspath"/>
> </java>
> 
> -- 
> 
> Francis Galiegue
> ONE2TEAM
> Ingénieur système
> Mob : +33 (0) 683 877 875
> Tel : +33 (0) 178 945 552
> fge@one2team.com
> 40 avenue Raymond Poincaré
> 75116 Paris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-To%3A-Java-Command-to-Ant-tp25512317p25605177.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How To: Java Command to Ant

Posted by Francis GALIEGUE <fg...@one2team.com>.
On Mon, Sep 21, 2009 at 02:34, dr_pompeii <dr...@yahoo.com> wrote:
>
> Hello supareno
>
> Thanks for the reply, but no woek :-(
>

Try this:

<path id="myclasspath">
    <!-- fill with whatever is necessary -->

<java fork="true" classname="com.jordan.Main" failonerror="true">
    <jvmarg value="-Dcom.sun.management.remote"/>
    <!-- Necessary nested <arg> elements here, but it looks like there
aren't any -->
    <classpath refid="myclasspath"/>
</java>

-- 

Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How To: Java Command to Ant

Posted by dr_pompeii <dr...@yahoo.com>.
Hello supareno

Thanks for the reply, but no woek :-(

This is the Main Class

public class Main {

    public static void main(String[] args) throws IOException {
        ApplicationContext context =
            new ClassPathXmlApplicationContext("beans.xml");

        FileReplicator documentReplicator =
            (FileReplicator) context.getBean("documentReplicator");

        try {
            MBeanServer mbeanServer =
ManagementFactory.getPlatformMBeanServer();
            ObjectName objectName = new
ObjectName("bean:name=documentReplicator");

            ............. a lot of lines  

            mbeanServer.registerMBean(mbean, objectName);
        } catch (JMException e) {
            System.out.println("+++ JMException +++");
        } catch (InvalidTargetObjectTypeException e) {
            System.out.println("+++ InvalidTargetObjectTypeException +++");
        } catch (NoSuchMethodException e) {
            System.out.println("+++ NoSuchMethodException +++");
        }

        System.in.read();
    }
}

Therefore, the original java command
java -classpath D:\TR\...a.jar;D:\TR\b.jar; -Dcom.sun.management.jmxremote
com.jordan.Main	

Is to "feed" the line in the main method  System.in.read();

Some suggestions are welcome

Thanks for your time




supareno wrote:
> 
> dr_pompeii,
> 
> you should try this:
> 
> <target ...>
>   <java ... >
>     [...]
>     <arg value="-Dcom.sun.management.jmxremote" />
>     [...]
>   </java>
> </target>
> (see http://ant.apache.org/manual/CoreTasks/java.html and 
> http://ant.apache.org/manual/using.html#arg)
> 
> i did it tonight on my linux box with a jdk6 and it works well :-)
> 
> hope this help
> 
> supareno
>> Dear Members
>>
>> I have this java comand (related with JMX)
>>
>> java -classpath D:\TR\...a.jar;D:\TR\b.jar;
>> -Dcom.sun.management.jmxremote
>> com.jordan.Main	
>>
>> This work, then I can get a connection from jconsole (PID from Local Tab
>> Pane)
>>
>> The point is that is a long classpath and work for windows, therefore
>> this
>> in Linux is heavy to be changed, 
>> I used to work with ant (I am not an expert), usually with this is enough
>>
>> <target name="run">				 
>>         <java fork="true" classname="com.jordan.Main"
>> classpathref="libraries">
>>             <classpath path="${bindir}"/>          
>>         </java>
>> </target>	 
>>
>> The code work, but I can never get a connection from jconsole because
>> never
>> appear any PID
>>
>> Therefore I need your knowledge, what is misssing in my ant configuration
>>
>> Thanks in advanced
>>   
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-To%3A-Java-Command-to-Ant-tp25512317p25530148.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How To: Java Command to Ant

Posted by supareno <re...@free.fr>.
dr_pompeii,

you should try this:

<target ...>
  <java ... >
    [...]
    <arg value="-Dcom.sun.management.jmxremote" />
    [...]
  </java>
</target>
(see http://ant.apache.org/manual/CoreTasks/java.html and 
http://ant.apache.org/manual/using.html#arg)

i did it tonight on my linux box with a jdk6 and it works well :-)

hope this help

supareno
> Dear Members
>
> I have this java comand (related with JMX)
>
> java -classpath D:\TR\...a.jar;D:\TR\b.jar; -Dcom.sun.management.jmxremote
> com.jordan.Main	
>
> This work, then I can get a connection from jconsole (PID from Local Tab
> Pane)
>
> The point is that is a long classpath and work for windows, therefore this
> in Linux is heavy to be changed, 
> I used to work with ant (I am not an expert), usually with this is enough
>
> <target name="run">				 
>         <java fork="true" classname="com.jordan.Main"
> classpathref="libraries">
>             <classpath path="${bindir}"/>          
>         </java>
> </target>	 
>
> The code work, but I can never get a connection from jconsole because never
> appear any PID
>
> Therefore I need your knowledge, what is misssing in my ant configuration
>
> Thanks in advanced
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org