You have a number of problems:
- You've misspelled "practice" in irb:
java_import 'com.pratice.Test'
Your class isn't actually in the correct package. You need to addpackage com.practice;
to the Java code.- You need to add "bin" to your classpath so that the JVM can find the classes:
$CLASSPATH << 'bin'
Altogether, I was able to run this in IRB:
$CLASSPATH << 'bin'
com.practice.Test.foo
# => "Java!!"
EDIT: I failed to copy your package
line, that's my fault, not yours. :-)