I’ve set up Couchbase Lite in my Android application and gotten it working successfully. However, I can’t figure out how to use the pure Java version on Windows. The download link for the Java Community Version of Lite on the website has a single jar that appears to be the wrong one (java-native-1.0.3.1.jar); it doesn’t contain any of the required classes. There don’t seem to be any tutorials for getting the pure, non-Android library set up in Eclipse. Any help with this would be appreciated.
Ok, I figured out how to build the libraries (java-core and java-native) and I’ve added the jars to my build path. However, there doesn’t seem to be any implementation of Context that I can use to create a Manager. What gives?
In the couchbase-lite-java library, it includes the JavaContext class. Take a look at that.
Ah, I hadn’t even seen that! That looks like just what I need. Unfortunately trying to build it from the command line results in an error: “Could not determine the dependencies of task ‘:compileJava’. Configuration with name ‘default’ not found.”
That sounds like it might be that you haven’t checked out the submodules.
Did you run git submodule init && git submodule update
?
Oops, forgot to read the github instructions… Funny how things tend to work better when you do that It builds further now, but fails on the testing stage; there is an UnsatisfiedLinkError in CollationTest. It looks like it’s missing a native DLL: “/native/windows/amd64/CouchbaseLiteJavaNative.dll”. I suspect this has something to do with “Toolchains for compiling native libraries as follows:” on the github page, although I have limited experience so I wouldn’t know. Thanks for trying to walk me through this.
Yes, you will need to install the toolchain for Windows. Please report anything you find here so I can try to get it back into the docs to help other users.
Ok, thanks. Once I have Visual Studio, what will I have to do to compile the DLLs?
Yes, just run ‘./gradlew build’ command. And you can zip all the jars by running ‘$ ./gradlew distZip’ after.
That worked perfectly; thanks to all of you. I definitely think the documentation should be more explicit about what is required and the fact that it will work “automagically” once the Visual portion is installed.
Dear,
I am new to couchbase lite, i am working with pure java and couchbase lite.
i am unable to run code mentioned on couchbase lite documentation.
i have created manager through code:
manager = new Manager(new JavaContext(“data”), Manager.DEFAULT_OPTIONS);
after creating manager i want to open db.iuse this:
Database db = manager.getDatabase(“sync_gateway”);
but this through exception
Apr 01, 2015 10:02:53 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Native: Library not found: /native/windows/amd64/CouchbaseLiteJavaNative.dll
Apr 01, 2015 10:02:53 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Native: Error loading library: CouchbaseLiteJavaNative
java.lang.NullPointerException
at com.couchbase.lite.util.NativeUtils.loadLibrary(NativeUtils.java:45)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine.(JavaSQLiteStorageEngine.java:125)
at com.couchbase.lite.storage.JavaSQLiteStorageEngineFactory.createStorageEngine(JavaSQLiteStorageEngineFactory.java:6)
at com.couchbase.lite.Database.open(Database.java:907)
at com.couchbase.lite.Manager.getDatabase(Manager.java:236)
at javaapplication16.JavaApplication16.onCreate(JavaApplication16.java:42)
at javaapplication16.JavaApplication16.main(JavaApplication16.java:67)
Exception in thread “main” java.lang.UnsatisfiedLinkError: com.couchbase.lite.storage.JavaSQLiteStorageEngine._open(Ljava/lang/String;)J
at com.couchbase.lite.storage.JavaSQLiteStorageEngine._open(Native Method)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine.access$100(JavaSQLiteStorageEngine.java:8)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine$Connection.(JavaSQLiteStorageEngine.java:23)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine$ConnectionPool.start(JavaSQLiteStorageEngine.java:46)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine.open(JavaSQLiteStorageEngine.java:138)
at com.couchbase.lite.Database.open(Database.java:910)
at com.couchbase.lite.Manager.getDatabase(Manager.java:236)
at javaapplication16.JavaApplication16.onCreate(JavaApplication16.java:42)
at javaapplication16.JavaApplication16.main(JavaApplication16.java:67)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
kindly help me, thanks in advance.
Hi @zeeshan_niazi,
CBL Java download package does not includes the native library for Windows platform. It only includes Linux binary. Could you please build couchbase-lite-java-native by yourself? Instruction is in README of GitHub - couchbase/couchbase-lite-java-native: This is a shared native SQLite library used for Couchbase Lite Android/Java. .
@pasin could you please follow up if necessary?
Thanks,
Hideki
hi,
i have downloaded and install gradle. than build couchbasse-lite-java-native-master code with grade.
it generates new folder with name build. in build\libs it generate the jar file “couchbase-lite-java-native-master.jar”. than i have include that jar file in my class path, but still i facing the same error:
Apr 02, 2015 5:51:02 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Native: Library not found: /native/windows/amd64/CouchbaseLiteJavaNative.dll
Apr 02, 2015 5:51:02 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Native: Error loading library: CouchbaseLiteJavaNative
java.lang.NullPointerException
at com.couchbase.lite.util.NativeUtils.loadLibrary(NativeUtils.java:45)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine.(JavaSQLiteStorageEngine.java:125)
at com.couchbase.lite.storage.JavaSQLiteStorageEngineFactory.createStorageEngine(JavaSQLiteStorageEngineFactory.java:6)
at com.couchbase.lite.Database.open(Database.java:907)
at com.couchbase.lite.Manager.getDatabase(Manager.java:236)
at javaapplication16.JavaApplication16.onCreate(JavaApplication16.java:42)
at javaapplication16.JavaApplication16.main(JavaApplication16.java:67)
Exception in thread “main” java.lang.UnsatisfiedLinkError: com.couchbase.lite.storage.JavaSQLiteStorageEngine._open(Ljava/lang/String;)J
at com.couchbase.lite.storage.JavaSQLiteStorageEngine._open(Native Method)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine.access$100(JavaSQLiteStorageEngine.java:8)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine$Connection.(JavaSQLiteStorageEngine.java:23)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine$ConnectionPool.start(JavaSQLiteStorageEngine.java:46)
at com.couchbase.lite.storage.JavaSQLiteStorageEngine.open(JavaSQLiteStorageEngine.java:138)
at com.couchbase.lite.Database.open(Database.java:910)
at com.couchbase.lite.Manager.getDatabase(Manager.java:236)
at javaapplication16.JavaApplication16.onCreate(JavaApplication16.java:42)
at javaapplication16.JavaApplication16.main(JavaApplication16.java:67)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Can you take a look if the jar file contains any libraries inside? Also are you having visual studio installed in your build machine?
i dont have visual studio installed my machine
ok i will install visual studio on my machine. than what i will do, after installing visual studio?
i have one other question.
what i am under standing from couchbase lite database is couchbase server databucket ?
After installing visual studio, you just run gradlew build
as you did before. Couchbase Lite is an embedded database that will be run inside an application. It has a replication feature that you can sync your data with Couchbase Server via Sync Gateway. You can learn more about couchbase mobile including couchbase lite from [here] (http://www.couchbase.com/nosql-databases/couchbase-mobile).
Also alternatively you could build all jar files including couchbase-lite-java-native library from couchbase-lite-java as well?
Just follow the instruction here after installing the visual studio:
OK, thanks, after installing visual studio, i will flow the instructions. and get back to you if i face any difficulty.
hi, i have installed visual studio and downloaded the latest code from:
when i run command “gradle build”.
i receive following errors:
C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master>gradle build
FAILURE: Build failed with an exception.
-
Where:
Build file ‘C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master\build.gra
dle’ line: 31 -
What went wrong:
A problem occurred evaluating root project ‘couchbase-lite-java-master’.
Project with path ‘:libraries:couchbase-lite-java-core’ could not be found in
root project ‘couchbase-lite-java-master’.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 3.495 secs
C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master>
C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master>gradle build
FAILURE: Build failed with an exception.
-
Where:
Build file ‘C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master\build.gra
dle’ line: 31 -
What went wrong:
A problem occurred evaluating root project ‘couchbase-lite-java-master’.
Project with path ‘:libraries:couchbase-lite-java-core’ could not be found in
root project ‘couchbase-lite-java-master’.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 3.495 secs
C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master>
C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master>gradle build
FAILURE: Build failed with an exception.
-
Where:
Build file ‘C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master\build.gra
dle’ line: 31 -
What went wrong:
A problem occurred evaluating root project ‘couchbase-lite-java-master’.
Project with path ‘:libraries:couchbase-lite-java-core’ could not be found in
root project ‘couchbase-lite-java-master’.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 3.495 secs
C:\Users\LENOVO B5400\Downloads\couchbase-lite-java-master>
Did you checkout the git submodules before building?