Yes, since almost any language environment works like regular code for a language, just by providing a framework for the applications you write, they can coexist well with other frameworks for the same or other languages. You can, of course, run Rails and the Java framework on one computer - you can even run Rails on JRuby and the Java application server
It looks like you are just starting to program. I would recommend learning some basics first. For example, if you want to learn Ruby, try the Pickaxe book , write some simple scripts, then go on to a ruby web structure like Sinatra or Rails. You will better understand the difference between the language and the framework, how each is installed and runs on your computer, etc.