• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java program and ant.jar  RSS feed

 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

A java prg was tried to go for creating a build file with minimum task and target
using the ant.jar file as shown below
Though the compilation   is ok but on executing
the error was indicated as below
*****************************
Hi
Subsequent to reediting the following java code, i obtained comilation errors.(notshown)

Actually tha ant.jar was tried as follows

jar -tf ant.jar

jar -xvf ant.jar from which i could get the META-INF
as well as org folder containing all the .class of
ant By using these two things

i tried to compile the java prg shown below
But the result is not so favouring probably the description that were given in between the java codes may not be proper .
Please try to help/revise the description that enable  the java program to render a ready made build.xml



Thanks
As
CRMK






 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before anyone can help you, we need at least the exact code you tried to compile and the error messages it produced.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:Before anyone can help you, we need at least the exact code you tried to compile and the error messages it produced.

Hi
Subsequent to reediting  java code, i obtained comiplation errors


Actually tha ant.jar was tried as follows

jar -tf ant.jar

jar -xvf ant.jar from which i could get the META-INF
as well as org folder containing all the .class of
ant By using these two things

i tried to compile the java prg shown below
But the result is not so favouring probably the description that were given in between the java codes may not be proper .
Please try to help/revise the description that enable  the java program to render a ready made build.xml
As

CRMK

*******************************


 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have copied and pasted much of your reply.  This isn't helpful. 

It is difficult to tell exactly what you're trying to do.  Please TellTheDetails but also IsolateTheProblem (those are links).
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:You have copied and pasted much of your reply.  This isn't helpful. 

It is difficult to tell exactly what you're trying to do.  Please TellTheDetails but also IsolateTheProblem (those are links).

Hi

Is there any ready  made java program for creating a build.Xml with one target and one task(minimum).The
Java prg shown(previous)  is just a sample one that i wanted to create .Contexualy
i made use of the ant.jar that is normally being supplie along with ant  But.I am surprised why the same java program
when iit s run from a java evironment is not producnig the build.xml file though compilation is without error
Please go through only code and tell if ok or not
Please note i mentioned anout ant jar just to make  you comprehend as to the way i started
Thanks
As
CRMK

 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the code above, the biggest problem is this:

Simply add e.printStackTrace(); and you can see that there is an error when you run the program.  Address those errors and post back here if you get stuck.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:In the code above, the biggest problem is this:

Simply add e.printStackTrace(); and you can see that there is an error when you run the program.  Address those errors and post back here if you get stuck.



Hi
Now after try/catch correctly entered
the codes are as follows



Now the runtime errors are the main hurdles inspite of the  many try by way of inclusion from ant tool;
Shall be thankful f this is made alright
Thanks
As
CRMK
 
 
 
 
 

 
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have an answer to your question about the NullPointerException, but I'd like to find out what you are trying to do.  It seems like you are trying to create a build.xml file for ant in Java.  Usually the build.xml file is created by hand.  Can you tell me why your trying to create it with Java?
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:I don't have an answer to your question about the NullPointerException, but I'd like to find out what you are trying to do.  It seems like you are trying to create a build.xml file for ant in Java.  Usually the build.xml file is created by hand.  Can you tell me why your trying to create it with Java?


Hi
Build file is normally created by hand only But when you are able to know about the important classes being avaiilable from an executable
jar (ant.jar) i do feel that a try out can be made using java prg and the minimum elements like target ,task,project  to create .This would
,on success be able to do a bigger build.xml
but neverthles,why the classes are rather difficult to be made use of for, build up inli-eu of only .class files being  avilable   from a jar.
(present scenerio is maximum java lang being sandwitched  wth ant classes and that too only .clases
The null pointer exceptions  always exist when an object is not readily  made during run time.which is tough  So this hurdle is first thing to get rid off,This is
for your perusal with thanks.
As
CRMK
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't find any way to generate an Ant build file from Java.  You can generate them from an IDE like Eclipse or IntelliJ.  In Eclipse, try File > Export > General > Ant buildfiles.

Generating an Ant buildfile from a Java program sounds like a monumental task.  I would try using an IDE first.

As for you NPE in your Java program, I only know that you should use...

https://ant.apache.org/manual/api/org/apache/tools/ant/Project.html#createTask-java.lang.String-

I don't know if this will clear it up or not.  I'm not familiar with the org.apache.tools.ant package and I can't find any documentation on how to use it.
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:I can't find any way to generate an Ant build file from Java.  You can generate them from an IDE like Eclipse or IntelliJ.  In Eclipse, try File > Export > General > Ant buildfiles.

Generating an Ant buildfile from a Java program sounds like a monumental task.  I would try using an IDE first.

As for you NPE in your Java program, I only know that you should use...

https://ant.apache.org/manual/api/org/apache/tools/ant/Project.html#createTask-java.lang.String-

I don't know if this will clear it up or not.  I'm not familiar with the org.apache.tools.ant package and I can't find any documentation on how to use it.


Hi

on the usual tryout methods &
removning the use of jar classes totally
since thre are no documentations available except the available .class files which seems to be of no help for the build-up work,
The following codes were tried
as a smpler one using the self made+radomcollectd ant.api(very approximately)the code was run in the java environment
as follws

javac ChapterAntProject.java

java ChapterAntProject.class

The NEW RESULTS were fetched which is not only  quite  relief  motivating at this jucture and requires further try

May I leave it to your good offices to do the needfull .I do not know how to include annotation process

This new venture of codes  is for your Perusal with thanks

As
CRMK

 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:I can't find any way to generate an Ant build file from Java.  You can generate them from an IDE like Eclipse or IntelliJ.  In Eclipse, try File > Export > General > Ant buildfiles.

Generating an Ant buildfile from a Java program sounds like a monumental task.  I would try using an IDE first.

As for you NPE in your Java program, I only know that you should use...

https://ant.apache.org/manual/api/org/apache/tools/ant/Project.html#createTask-java.lang.String-

I don't know if this will clear it up or not.  I'm not familiar with the org.apache.tools.ant package and I can't find any documentation on how to use it.


Hi
On another instant when
i  used the code with system.out.println(proj1);

the resiult indicates a db id-
**************
ChapterAntProject@1db9742
*************
please tell me what this meansThanks
As
CRMK
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comal Rajagopalaratnam Muthukumar wrote:
javac ChapterAntProject.java

java ChapterAntProject.class

Java takes a class name, not a class file name.  That means you should execute your program like this:

java ChapterAntProject
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Comal Rajagopalaratnam Muthukumar wrote:
Hi
On another instant when
i  used the code with system.out.println(proj1);

the resiult indicates a db id-
**************
ChapterAntProject@1db9742
*************
please tell me what this meansThanks
As
CRMK

When you print an object System.out.println() looks for a toString() method in the object's class.  If none is found, it looks in the superclass, until it gets to the Object class.  All objects are subclasses of Object, so you are seeing Object's toString() method.  It prints the class name, an @, and a reference to the object's place in memory (not very useful, but it works).  If you want to see something different, override the toString() class in ChapterAntProject.
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

A class that doesn't extend any other class explicitly will extend class Object implicitly, so there's no need for "extend java.lang.Object".

Also, everything in java.lang is implicitly imported in every class, so you don't have to write java.lang.Object, just Object.
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The formatting of your code isn't helping you.  I consider poor formatting a bug.  Here's how you code looks just by using Eclipse and pressing Ctrl-Shift-F:
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a misspelling of the method execte?
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still have the question: what are you trying to do with this code?
 
Comal Rajagopalaratnam Muthukumar
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:I still have the question: what are you trying to do with this code?


Hi

Indeed I totally agree with you the buildfile making via java prg is so complex that it requires a ready made documents.
As i earlier itsef  indicated just out of curiosity I did try many methods.Also the reason for the complexity is too many
clubbings of methods(betweenjava and ant classes)
The follwing last resort
i tried in a reverse way ie) build.xml being made by hand.and the same java program(which compiles ok)  being placed in the src
folder under ant base dir This resulted in yet another new error as shown below

Hence i now say cheerio to this.

The details for your perusal with thanks
Thanks
Cheers
As
CRMK

*********************************

****************************************


build.xml
*****************************


****************************

C:\Program Files\apache-ant-1.10.1\bin>ant
Buildfile: C:\Program Files\apache-ant-1.10.1\bin\build.xml

jonsTarget:

BUILD FAILED
C:\Program Files\apache-ant-1.10.1\bin\build.xml:4: taskdef class GreetJon ca
t be found
using the classloader AntClassLoader[]

******************************
 
Knute Snortum
Sheriff
Posts: 3615
87
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I finally know what you're trying to do.  Are you trying to write a Java program that can be called from an ant task?  If so, it's much simpler than you've made it.  The directions are here.  My Java class:

And I called it with a build.xml file like this:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!