Nitish Upreti
Nitish Upreti

Reputation: 6550

Executing initialization code before java_import in JRuby?

Does java_import always execute before initialize in JRuby?

I need the following code to execute

def initialize vlc_path
    @vlc_path = vlc_path || get_vlc_path
    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName,"/Applications/VLC .app/Contents/MacOS/lib")
end

before I can use:

java_import 'uk.co.caprica.vlcj.binding.LibVlc'

The java_import always executes first and fails. How to go about it?

Upvotes: 0

Views: 52

Answers (1)

Jörg W Mittag
Jörg W Mittag

Reputation: 369633

Methods get called when they get … well … called. If you call initialize before you call java_import it will execute first, if you call it after java_import it will execute after java_import.

If you want to call initialize before you call java_import, you need to call initialize before you call java_import.

Upvotes: 1

Related Questions