Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you compile java program?

 
Justin Thomas
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Justin Thomas
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21122
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Justin Thomas
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21122
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21122
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:You need to figure out what your Ant script does with it -- and fix accordingly.

Henry


How?
 
Henry Wong
author
Marshal
Pie
Posts: 21122
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, despire the fact that the library itself has some issues, the ant compilation process works, so this topic is done.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic