Question: [ 91%] Generate files for Java bindings
Traceback (most recent call last):
 File "/home/fcemtopall/Masaüstü/opencv-3.4.1/modules/java/generator/../generator/gen\_java.py", line 1093, in 
 copy\_java\_files(java\_files\_dir, target\_path)
 File "/home/fcemtopall/Masaüstü/opencv-3.4.1/modules/java/generator/../generator/gen\_java.py", line 1032, in copy\_java\_files
 src = checkFileRemap(java\_file)
 File "/home/fcemtopall/Masaüstü/opencv-3.4.1/modules/java/generator/../generator/gen\_java.py", line 25, in checkFileRemap
 assert path[-3:] != '.in', path
AssertionError: /home/fcemtopall/Masaüstü/opencv-3.4.1/modules/java/generator/src/java/org/opencv/osgi/OpenCVNativeLoader.java.in
modules/java\_bindings\_generator/CMakeFiles/gen\_opencv\_java\_source.dir/build.make:315: recipe for target 'CMakeFiles/dephelper/gen\_opencv\_java\_source' failed
make[2]: **\* [CMakeFiles/dephelper/gen\_opencv\_java\_source] Error 1
CMakeFiles/Makefile2:2686: recipe for target 'modules/java\_bindings\_generator/CMakeFiles/gen\_opencv\_java\_source.dir/all' failed
make[1]: \*** [modules/java\_bindings\_generator/CMakeFiles/gen\_opencv\_java\_source.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: \*\*\* [all] Error 2

Answer: 
```
@Override
public Observable<User> findUser() {
  return Observable.create(new ObservableOnSubscribe<User>() {
    @Override
    public void subscribe(ObservableEmitter<User> emitter) throws Exception {
        try(Realm realm = Realm.getDefaultInstance()) {
            realm.refresh();
            User user = realm.where(User.class).findFirst();
            User user1 = realm.copyFromRealm(user);
            emitter.onNext(user1);
            emitter.onComplete();
        } catch (Exception e) {
            emitter.onError(e);
        }
    }
  });
}

```
As the error says 

> 
> Realm objects can only be accessed on the thread they were created
> 
> 
> 

So just subscribe on the same thread you created Realm

```
userRepository.findUser()
            .subscribeOn(AndroidSchedulers.mainThread())
            .observeOn(AndroidSchedulers.mainThread())

```