0

I am building a little something in Java that uses Wolfram|Alpha to come up with integrals. I downloaded the Wolfram API and it comes with a sample program that you can use to figure stuff out. Here's that at GitHub.

There's a portion in the comments that says:

 * To compile or run this program you will need the following dependent 
 * libraries on your classpath (including WolframAlpha.jar, of course):
 * 
 *     commons-codec-1.3.jar
 *     httpclient-4.0.1.jar
 *     httpcore-4.0.1.jar
 *     commons-logging.jar

... and I have no idea how to do this. I'm using this project as a way to learn Java, so I am skipping a bunch of sleep-inducing fundamentals.

Are these libraries available in the vanilla Java install, or do I have to go fetch them from elsewhere? I want to avoid loading up my system with redundant stuff.

When I try to run the script without loading these libraries it ends in an error, predictably. Here's the error message:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/scheme/SocketFactory
    at com.wolfram.alpha.net.HttpProviderFactory.getDefaultHttpProvider(HttpProviderFactory.java:18)
    at com.wolfram.alpha.WAEngine.<init>(WAEngine.java:36)
    at simpleSample.main(simpleSample.java:58)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.scheme.SocketFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 3 more

I am using Eclipse as my IDE. I don't think it matters here, but it might.

n8.
  • 1,732
  • 3
  • 16
  • 38
  • @Jens I agree that this problem has been addressed elsewhere. Unfortunately it does not appear to be a duplicate as you marked it. – Tim Biegeleisen Sep 08 '15 at 07:32
  • Please have a look [here](http://stackoverflow.com/questions/9395207/how-to-include-jar-files-with-java-file-and-compile-in-command-prompt) to get you started. You can also look into using a Maven project to handle your dependencies. – Tim Biegeleisen Sep 08 '15 at 07:32
  • 2
    "I am skipping a bunch of sleep-inducing fundamentals", but now those sleep inducing fundamentals are giving you a headache. Maybe you should start by invoking `java -h` and have a look at the `-classpath` option. – SpaceTrucker Sep 08 '15 at 07:43
  • From the readme of the project you linked - *These libraries are widely available on the Internet. You can probably use other version numbers than these, although these are the versions I used.* Yet another sleep-inducing fundamentals - Read a readme. – Aleksandr M Sep 08 '15 at 08:38
  • I find it ironic that multiple people are responding that I am not doing my due diligence reading many thousands of pages of documentation when they themselves cannot read a full question. Namely this: "Are these libraries available in the vanilla Java install, or do I have to go fetch them from elsewhere? I want to avoid loading up my system with redundant stuff." Please take into account that I am attempting to learn, not just spam my computer with whatever makes my errors go away. – n8. Sep 08 '15 at 09:03

3 Answers3

1

You have to upgrade the httpclient.jar to version 4.1. As you can see in the javadoc theses class available from this version

Jens
  • 67,715
  • 15
  • 98
  • 113
1

These are all (old) Apache Software Foundation libraries. The download locations are as follows:

commons-codec-1.3.jar

httpclient-4.0.1.jar

commons-logging.jar

httpcore-4.0.1.jar

dimplex
  • 494
  • 5
  • 9
  • I'll end up doing this if I have to, but this does not address my question. I already have a lot of libraries, I don't want to add a bunch of redundant ones if I can help it. – n8. Sep 08 '15 at 09:07
1

@dimplex has already answered. These are releases of several Apache projects. Next time you meet these problems, try:

Google:

Like:

The first result for EVERY search above is a couple clicks away from the download you're looking for.

Maven Central Search:

http://search.maven.org

(I'm not copying every link, just search for the Jar file names.)

This one is even more direct, but I'd recommend the Google way, as you can get a glimpse of the project page.

  • I know I could google and install every time I run into a problem. If you read my question you would see this passage: "Are these libraries available in the vanilla Java install, or do I have to go fetch them from elsewhere? I want to avoid loading up my system with redundant stuff." Thank you for your effort, though. – n8. Sep 08 '15 at 08:52
  • @n8. "Are these libraries available in the vanilla Java install, or do I have to go fetch them from elsewhere?". "These are releases of several Apache projects" answers that as a "No", and the rest of the answer tells you where that "elsewhere" is to "fetch" them. What's the problem? –  Sep 08 '15 at 09:21
  • The problem is in assuming that I know things. I didn't know that Java wouldn't include those libraries, that's why I asked if they were included. Sure, it stands to reason that Java wouldn't necessarily include Apache libraries in their vanilla install, but I don't know that. So instead of making uninformed decisions, I ask the question. Thank you for answering comprehensively, but I really just needed a "no, what you need must be downloaded." – n8. Sep 08 '15 at 09:39