Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure JRuby

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to install and configure JRuby, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

First, determine the JRuby installation environment

Before installing JRUBY, you must first determine the version of JDK on this machine. If you are using jruby 1.1.1, you can use jdk 1.4 (from the network, not personally certified), but if you are using jruby 1.1.2, then the version of JDK * * is 1.6. Some of the earlier versions of JDK1.5 may not be supported. I did not prove the specific version correspondence one by one, because it is actually quite cumbersome and I did not find the documentation.

II. Version acquisition

Download of JRUBY: http://dist.codehaus.org/jruby/jruby-bin-1.1.2.zip

JAVA 1.6download: http://192.18.108.239/ECom/EComTicketServlet/BEGIN31DA9601C7CEF4A95D66372DE469CD8C/-2147483648/2617791231/1/877946/877778/2617791231/2ts+/westCoastFSEND/jdk-6u5-oth-JPR/jdk-6u5-oth-JPR:2/jdk-6u5-windows-i586-p.exe

Java 1.6Chinese API: http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/chm/JDK_API_1_6_zh_CN.CHM

(this document also seems to have been translated directly by translation software.)

3. JRuby installation:

The installation of JRUBY is quite simple, first unpack the downloaded package to any directory, and then add JRUBY_HOME to the environment variable to point to your unzipped directory. Then add / jruby-1.1.2/bin to PATH

Not to mention the installation and configuration of JDK, there are a lot of searches on the Internet.

4. JRuby configuration: verify that JRuby is installed correctly

To configure JRuby, go to the CMD command line and enter jruby-v, and the output should be as follows:

Ruby 1.8.6 (2008-05-28 rev 6586) [x86-jruby1.1.2] 'cmd' is not an internal or external command, nor is it a runnable program or batch file.

I've been depressed about what happened to that prompt.

Enter HELLO WORLD:

Add a HelloWorld.rb file to the root directory of the C disk. Edit the file in notepad and enter the following:

Puts "Hello world"

Save and exit, then type jruby HelloWorld.rb in CMD, enter enter, and the output should see HelloWorld, so the installation is complete.

Then we try to call the class of JAVA with JRUBY and modify the HelloWorld.rb file as follows:

Require 'java' include_class ("java.lang.System") System.out.println ("hello world") saves and exits after modification, goes to the cmd command line, and executes the following command: the jruby HelloWorld.rb output should implement hello world, proving that jruby is ready to call the methods of the JAVA class. But the current problem is that I don't know how to call the custom JAVA class yet.

Keep in mind that if you use jruby-1.1.2, do not use JDK 1.4. if you are prompted to find the main method when running a JRUBY program, or if the org.ruby.main is not defined, it is probably due to version inconsistencies. My personal advice is that if you use jruby-1.1.2, install jdk 1.6; if you don't use jruby-1.1.2, then use jruby-.1.1.2 instead.

Note: in the process of JRuby configuration or testing JRuby installation, the error message in the output result of the script run is *:

'cmd' is not an internal or external command, nor is it a runnable program or batch file.

I stumbled upon the following ways to solve the problem: go to the bin directory under the jruby directory, change the jruby.bat file name to any, and then execute the ruby script under the cmd command line, this error prompt will not be displayed, and I don't know why yet. That's all you need to know about JRuby configuration for the time being.

These are all the contents of the article "how to install and configure JRuby". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report