As title says i whant to change my variables in java from my jruby code
To be more specific i have an integer in my Java code which has no value yet, And i whant with my JRuby code give this variable an value, But i have no idea how to do this.
This is how far i got with the JRuby code..
require 'java'
puts "Set player health here"
playerHealth = 3 # Setting player health here!
But have not yet wrote anything in java. This is pretty much all I have so far..
From what I understand, you are trying to invoke the JRuby engine from Java, so you could do something like this to modify a Java variable in JRuby:
Note that in the script
playerHealthis a global variable.Check out this link for more details if you want to load an external JRuby script rather than evaluating code.