Eclipse maven tensorflow project confused about java version

I have java 18 (not 1.8) on windows 10. Trying the example program from the installation guide gets the errors below.

Look like the compiler is confused about the version.

All of the code from the java models has this problem also.

|Method references are allowed only at source level 1.8 or above||/1/src/main/java/p|line 14|Java Problem|

|References to interface static methods are allowed only at source level 1.8 or above||/1/src/main/java/p|line 15|Java Problem|

|Resource specification not allowed here for source level below 1.7||/1/src/main/java/p|line 14|Java Problem|

The examples set the source level to 1.8, so I think this is a misconfiguration in your Eclipse project.

i tried installing with gradle, but that failed as it did not like the dependency line: implementation ‘org.tensorflow’, name: ‘tensorflow-core-platform’, version: ‘0.3.3’ it complains about the format.

so i am using elipse with maven. i don’t know anythin abot maven. switching to 1.8 helped a lot. but i still get some erroes (please see below).

can i just donwload some jars from somewhere? can they be fished out of maven somehow?

i trtied but it

and followed the instruction here Add .dll to java.library.path in Eclipse/PyDev Jython project - Stack Overflow but the dll only shows up under source and not at all in libraries.

The import org.tensorflow.framework cannot be resolved

i have very poor vision due to some receny eye sugery, so it’s hard to see all of the problems and i may be missing something obvious.


AdaDelta cannot be resolved to a type

GradientDescent cannot be resolved to a type

Momentum cannot be resolved to a type

Optimizer cannot be resolved to a type

For gradle to include the platform dependency you might need to use something like implementation "org.tensorflow:tensorflow-core-platform:0.4.2@pom" as the platform dependency is just a pom file that pulls in other dependencies.

The jars can be downloaded from Maven Central by searching at and pulling down the appropriate files (e.g. Central Repository: org/tensorflow/tensorflow-core/0.4.2), but it’s preferable to get Maven or Gradle running properly as it’ll handle the platform specific native dependencies better.

trying the @pom gets a can not import. from command line (please see below(. running in eclipse gets a reallly long stakc trace trhat i can not read.

i will try ti diwbkiad the jars.


plugins { id ‘java-library’ }
repositories { mavenCentral() }
java {
toolchain {
//languageVersion = JavaLanguageVersion.of(“1.8”)
dependencies {
testImplementation ‘org.junit.jupiter:junit-jupiter:5.8.1’
api ‘org.apache.commons:commons-math3:3.6.1’
implementation ‘’
implementation “org.tensorflow:tensorflow-core-platform:0.4.2@pom”
tasks.named(‘test’) { useJUnitPlatform() }
<-------------> 0% INITIALIZING [57ms]
<-------------> 0% INITIALIZING [356ms]
-------------> 0% CONFIGURING [453ms]

<============= 0% CONFIGURING [453ms]
<-------------> 0% EXECUTING [656ms]

<-------------> 0% EXECUTING [656ms]
<-------------> 0% EXECUTING [749ms]
<-------------> 0% EXECUTING [857ms]f :lib:com
<-------------> 0% EXECUTING [857ms]
<-------------> 0% EXECUTING [1s]

<-------------> 0% EXECUTING [1s]

Task :lib:compileJava FAILED
D:\tensorflow\g1\lib\src\main\java\g1\ error: package org.tensorflow does not exist
import org.tensorflow.*;
1 error

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:lib:compileJava’.

Compilation failed; see the compiler error output for details.

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

1 actionable task: 1 executed
<-------------> 14% EXECUTING [1s]

You still need to add tensorflow-core-api and tensorflow-framework as dependencies in addition to platform. The platform dependency pulls in the native parts, the other two I mentioned are the Java apis.

found libtensorflow-1.14.0.jar and added it to the went back to the maven project. stil getting the can not import and can not find AdaFrad stuff.

but id did find the jars in m2 (please see below).

i will start a new peoject and stuff the jars into lib and see how far i get.

thanks again for your prompt assistance.





only 21 errors in new project (6 are duplicates).

where do these guys live?


Add cannot be resolved to a type
ConcreteFunction cannot be resolved
ConcreteFunction cannot be resolved to a type
Ops cannot be resolved to a type
Placeholder cannot be resolved to a type
Signature cannot be resolved
Signature cannot be resolved to a type
Tensor cannot be resolved to a type
TensorFlow cannot be resolved
The import org.tensorflow.op.core.Placeholder cannot be resolved
The import org.tensorflow.op.math.Add cannot be resolved
The import org.tensorflow.op.Ops cannot be resolved
The import org.tensorflow.types.TInt32 cannot be resolved
The import org.tensorflow cannot be resolved
TInt32 cannot be resolved
TInt32 cannot be resolved to a type
TInt32 cannot be resolved to a type
TInt32 cannot be resolved to a type
TInt32 cannot be resolved to a type
TInt32 cannot be resolved to a type
TInt32 cannot be resolved to a type

Those live in tensorflow-core-api. You should not mix the old libtensorflow v1.x jars with the newer tensorflow-core v0.x jars, that’ll cause weird errors.

TInt32 is indeed in tensorflow-core-api-0.4.2.jar. so i am wondering why eclipse is complaining.

How am i mixing the old lib stuff? is that in the 0.3.3 jars? or is that the TInt32 stuff?

the simple program below fails wiith a no class fould.


D:\tensorflow\2>java -cp src p.Foo
Exception in thread “main” java.lang.NoClassDefFoundError: org/te
at p.Foo.main(
Caused by: java.lang.ClassNotFoundException: org.tensorflow.Tenso
at java.base/jdk.internal.loader.BuiltinClassLoader.loadC
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoa
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.
… 1 more

package p;
import org.tensorflow.TensorFlow;
public class Foo {
    public static void main(String[] args) {
        System.out.println("Hello TensorFlow "+TensorFlow.version());

Your previous post mentioned downloading libtensorflow-1.14.0, I was saying that you shouldn’t use that. If you only have tensorflow-core-api 0.4.2, tensorflow-core-platform 0.4.2 and ndarray 0.3.3 you should be ok.

I don’t know why java isn’t loading those jars when executing the single source file, nor why Eclipse is misconfigured.

i am not usingg any dll. i am getting a clean compile with eclipse when using jre 1.8. tring to print the version gets a can not find, while try(ConcreteFunction dbl=ConcreteFunction.create(HelloTensorFlow::dbl); gets a can not find org/bytedeco/javacpp/Pointer.

looks like some kind of class loader problem.


Those are two dependencies of tensorflow-core-api, you need protobuf-java v3.19.4 and javacpp v1.5.6.

it works! i got: 10 doubled is 20

how did you figure out that i needed those versions? i had those jars in my .m2 repos but i could not find them in the pom.xml sample.


They are listed as dependencies in tensorflow-core-api’s pom, but the version numbers are given in the parent poms of that project.

i clone the repo again and imported it into eclipse as a maven project. this all works fine.

thanks again for your assistance.