File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes How do you compile java program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How do you compile java program?" Watch "How do you compile java program?" New topic
Author

How do you compile java program?

Justin Thomas
Ranch Hand

Joined: Mar 08, 2012
Posts: 62
1. There is a project
2. Project has build.xml
3. I exucte "ant" command in the folder
4. I get this: http://pastebin.com/m7uGuA87
5. I pasted the "lib" folder (inlcuding the jars) into like 10 different places. I still get 100 errors.

How do you compile a java program?
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

The first error says : /home/min/Downloads/PBapi1.4.3/api-java/core/src/com/photobucket/api/core/PhotobucketAPI.java:38: error: package org.apache.http.client.methods does not exist

This seems to be classpath issue.

Please make sure that all relevant jars are in classpath.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Justin Thomas
Ranch Hand

Joined: Mar 08, 2012
Posts: 62
I already told you I copied the folder "lib" containing all the jars in *counts carefully* 8 different places. I don't know where ELSE I have to copy it for the compiler to see them....
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Justin Thomas wrote:I already told you I copied the folder "lib" containing all the jars in *counts carefully* 8 different places. I don't know where ELSE I have to copy it for the compiler to see them....


It doesn't work that way, you can't copy jar files into a classpath (which is actually not a good idea regardless). A classpath specified both directories and jar files -- the directories (like the jar files) are searched only for class files; putting a jar file into these directories doesn't add them to the search. You need to add the jar file to the classoath (meaning the classpath variable needs to mention the jar file).

Henry
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14268
    
  21

You'd have to look into the Ant build file (build.xml) to find out where it expects to find the necessary library JAR files.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Justin Thomas
Ranch Hand

Joined: Mar 08, 2012
Posts: 62
Henry Wong wrote:
It doesn't work that way, you can't copy jar files into a classpath (which is actually not a good idea regardless). A classpath specified both directories and jar files -- the directories (like the jar files) are searched only for class files; putting a jar file into these directories doesn't add them to the search. You need to add the jar file to the classoath (meaning the classpath variable needs to mention the jar file).

Henry


I didn't understand your explanation.

As far as build.xml goes -> http://pastebin.com/kDQTcbHV
This is the first time I opened build.xml file in my life.... I noticed:
<property name="lib.dir" value="lib"/>

And in the main folder there already IS a lib dir that contains the jars.... so I am even more confused right now....
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Jesper de Jong wrote:You'd have to look into the Ant build file (build.xml) to find out where it expects to find the necessary library JAR files.


To elaborate, this would also depend on the Ant file. I have seen some that parses a directory for jar files and create a classpath accordingly. More commonly, is a variable which lists the jar files to be included. And unfortunately, since an Ant file is a script, I have also seen tons of bad stuff too.... debugging badly written Ant files are no fun...

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Justin Thomas wrote:
I didn't understand your explanation.

As far as build.xml goes -> http://pastebin.com/kDQTcbHV
This is the first time I opened build.xml file in my life.... I noticed:
<property name="lib.dir" value="lib"/>

And in the main folder there already IS a lib dir that contains the jars.... so I am even more confused right now....


All that line does is set a variable named "lib.dir" to a value of "lib". You need to figure out what your Ant script does with it -- and fix accordingly.

Henry
Justin Thomas
Ranch Hand

Joined: Mar 08, 2012
Posts: 62
Henry Wong wrote:You need to figure out what your Ant script does with it -- and fix accordingly.

Henry


How?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Justin Thomas wrote:
Henry Wong wrote:You need to figure out what your Ant script does with it -- and fix accordingly.

Henry


How?


Sorry. I don't work on Ant scrpts enough to have any magic bullet tricks. The last few times that I did it, I merely brute forced it -- running ant in debug mode and adding lots of echos to the screen,

I am sure that there are ant script debuggers out there -- and someone else can chime in.

Henry

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
This appears to be an Ant-related topic, rather than “beginning Java™”, so I shall move it to our Ant forum.
Justin Thomas
Ranch Hand

Joined: Mar 08, 2012
Posts: 62
Henry Wong wrote: The last few times that I did it, I merely brute forced it -- running ant in debug mode and adding lots of echos to the screen,

I am sure that there are ant script debuggers out there -- and someone else can chime in.

Henry



I refuse to learn yet another absolutely totally completely utterly useless technology that I will use and see only once in my entire life. Isn't there any smart way to fix it?
Is hardcore brute-forcing the only way?
Justin Thomas
Ranch Hand

Joined: Mar 08, 2012
Posts: 62
I guess this is the key:



It finally compiled. It even ran the tests. If it works - I will check in a moment....
Justin Thomas
Ranch Hand

Joined: Mar 08, 2012
Posts: 62
Ok, despire the fact that the library itself has some issues, the ant compilation process works, so this topic is done.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you compile java program?