4

i would like to use the Guava's TypeToken, then i downloaded the Guava Release 14.0 from here. (i assume 14.0 is more stable than 15.0 rc.)

guava-14.0.1-sources.jar (Source) 
http://search.maven.org/remotecontent?filepath=com/google/guava/guava/14.0.1/guava-14.0.1-sources.jar

Unzip the downloaded guava-14.0.1-sources.jar into a folder.

Then i created a Java 1.7 project in Eclipse.

And linked the source in Eclipse by Java Build Path -> Source -> Link Source....

Note i am not using (and don't know how to use) any build systems like Maven.

First i got a problem of The import javax.annotation.Nullable cannot be resolved. But this is solved already. i followed the thread here to download jsr305-2.0.1.jar from this page. (i assume 2.0.1 is the most latest release.)

Secondly i got the rt.jar access restriction problem like this one. This is also solved by simply re-add the JRE System Library, like the answer there.

Now i got this problem that i cannot solve, and there are no solutions from the web.

In package com.google.common.util.concurrent class ServiceManager, there are a few compile errors.

import javax.inject.Inject;         // The import javax.inject cannot be resolved
import javax.inject.Singleton;      // The import javax.inject cannot be resolved

To my understanding, this is a similar problem with the "first problem". But the jsr305-2.0.1.jar includes javax.annotation.Nullable, but it does not include javax.inject.*. What i need is a Java library that includes javax.inject.*.

Could you please help? Thanks a lot!

Community
  • 1
  • 1
midnite
  • 5,157
  • 7
  • 38
  • 52
  • P.S. In another project, i downloaded the [guava-14.0.1.jar](http://search.maven.org/remotecontent?filepath=com/google/guava/guava/14.0.1/guava-14.0.1.jar) from [the Guava Release](http://code.google.com/p/guava-libraries/wiki/Release14). Add it into my Eclipse project in `Java Build Path -> Libraries -> Add External JARs...`. i got **none** of the three problems mentioned above. It works so well. But i would like to study (and possibly modify) the source. – midnite Sep 04 '13 at 14:24

2 Answers2

16

The javax.inject package is provided in Java EE. If you're needing to use it in Java SE for some reason, you can explicitly include a jar with the API interfaces in it. Maven Central has a link to an implementation (javax.inject:javax.inject). Actually using Maven will make life simpler, but you can just download the jar file and include it manually.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
4

You can get the javax.inject jar here. You don't need to use maven, just download the .jar.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724