Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classes not found: org.bytedeco.javacpp.BytePointer and org.bytedeco.javacpp.Pointer #27

Closed
g00dnatur3 opened this issue Aug 22, 2014 · 10 comments

Comments

@g00dnatur3
Copy link

Is there a reason i keep getting ClassNotFound issues for org.bytedeco.javacpp.BytePointer and org.bytedeco.javacpp.Pointer?

I'm using this version in my sbt: "org.bytedeco" % "javacv" % "0.9"

Am I missing something or is this a bug...

Thanks for the help

@saudet
Copy link
Member

saudet commented Aug 23, 2014

@jpsacha Would you have an idea of what might be happening? It seems like the JavaCPP dependencies are not getting pulled in.

@jpsacha
Copy link
Member

jpsacha commented Aug 24, 2014

I cannot reproduce the issue. I am running Cookbook examples with no problem (with 0.9). I had an issue in FlyCapture2 with a missing libiomp5md.dll (still need to figure that one out, something happened in 0.9, I just added it to path), I am running it it with 0.9.1-SNAPSHOT. But that does not seem to be related. The error report is not very specific about how to reproduce the issue.
@saudet Can you reproduce it?

@saudet
Copy link
Member

saudet commented Aug 24, 2014

Thanks for the feedback @jpsacha. I haven't tried to figure it out myself, no. @g00dnatur3 please provide more details about how we may go about reproducing your issue, thanks.

@g00dnatur3
Copy link
Author

I'm using a MacBook pro with Eclipse Kepler & jdk 7.

I have a very simple Play Framework java project. I go ahead and add the sbt dependency of the 0.9 version.
There are no compile errors, it just gives me the exception when I run it using a main method.

I will post the sample code later, I don't have it with me-- but its very simple example code taken from stack overflow.

@saudet
Copy link
Member

saudet commented Aug 25, 2014

Containers like that usually have special instructions for libraries using JNI. Make sure you follow those instructions as well. Thanks

@shirish87
Copy link

This issue seems to occur for SBT (0.13.5) projects (Play uses SBT).

  • Create a file build.sbt
libraryDependencies ++= Seq(
  "org.bytedeco" % "javacv" % "0.9",
  "org.bytedeco" % "javacpp" % "0.9"
)
  • Create a file src/main/java/Test.java
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacpp.Pointer;

public class Test {
    public static void main(String[] args) {
        System.out.println("Test access");
    }
}
  • Run sbt run
[error] /var/apps/ar/te/src/main/java/Test.java:2: error: cannot find symbol
[error] import org.bytedeco.javacpp.Pointer;
[error]                            ^
[error]   symbol:   class Pointer
[error]   location: package org.bytedeco.javacpp
[error] 1 error
[error] (compile:compile) javac returned nonzero exit code
  • Copying the javacpp-0.9.jar file to the classpath lib folder and then running sbt run works.

Gradle works just fine, so I suspect this has something to do with the way SBT handles the javacpp POM.

apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'Test'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.bytedeco:javacv:0.9'
    compile 'org.bytedeco:javacpp:0.9'
}

@jpsacha
Copy link
Member

jpsacha commented Aug 29, 2014

In SBT you need to also load opencv presets including native binaries:

val javacppVersion = "0.9"

libraryDependencies ++= Seq(
  "org.bytedeco"                 % "javacv" % javacppVersion,
  "org.bytedeco.javacpp-presets" % "opencv" % ("2.4.9-" + javacppVersion) classifier "",
  "org.bytedeco.javacpp-presets" % "opencv" % ("2.4.9-" + javacppVersion) classifier platform,
)

If you know the platform you are running on you can hard-code it. You can also determine it automatically:

val platform = {
  // Determine platform name using code similar to javacpp
  // com.googlecode.javacpp.Loader.java line 60-84
  val jvmName = System.getProperty("java.vm.name").toLowerCase
  var osName = System.getProperty("os.name").toLowerCase
  var osArch = System.getProperty("os.arch").toLowerCase
  if (jvmName.startsWith("dalvik") && osName.startsWith("linux")) {
    osName = "android"
  } else if (jvmName.startsWith("robovm") && osName.startsWith("darwin")) {
    osName = "ios"
    osArch = "arm"
  } else if (osName.startsWith("mac os x")) {
    osName = "macosx"
  } else {
    val spaceIndex = osName.indexOf(' ')
    if (spaceIndex > 0) {
      osName = osName.substring(0, spaceIndex)
    }
  }
  if (osArch.equals("i386") || osArch.equals("i486") || osArch.equals("i586") || osArch.equals("i686")) {
    osArch = "x86"
  } else if (osArch.equals("amd64") || osArch.equals("x86-64") || osArch.equals("x64")) {
    osArch = "x86_64"
  } else if (osArch.startsWith("arm")) {
    osArch = "arm"
  }
  val platformName = osName + "-" + osArch
  println("platform: " + platformName)
  platformName
}

You can see an example of a complete build.sbt file in javacv-examples.

@shirish87
Copy link

Aah, thanks so much @jpsacha. My original sbt was missing: classpathTypes += "maven-plugin".
Should've checked the examples :(

@saudet
Copy link
Member

saudet commented Aug 29, 2014

Thanks @shirish87! @g00dnatur3, does adding the classpathTypes += "maven-plugin" fixes the issue for you as well?

@saudet
Copy link
Member

saudet commented Dec 27, 2014

Well, I've added that to the README.md file for version 0.10, so if there's anything that's unclear, please let me know. Thanks for the tips!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants