- 1 year ago
JRuby fresh install on Windows 10 - Could not find or load main class org.jruby.Main
If you encounter the error "Could not find or load main class org.jruby.Main" when trying to run JRuby on Windows 10, it's likely due to an issue with the JRuby installation or configuration. To resolve this problem, follow these steps:
Download and Extract JRuby:
Make sure you have downloaded the latest stable version of JRuby from the official website (https://www.jruby.org/download) or from a reliable source. Extract the downloaded archive to a directory of your choice.Set JRuby Home Environment Variable:
Set theJRUBY_HOME
environment variable to point to the directory where you extracted JRuby. This environment variable tells the Java Virtual Machine (JVM) where to find the JRuby installation.- Right-click on "This PC" or "My Computer" and select "Properties."
- Click on "Advanced system settings."
- In the System Properties window, click the "Environment Variables" button.
- In the "System Variables" section, click the "New" button.
- Set the variable name as
JRUBY_HOME
and the variable value as the path to your JRuby installation directory (e.g.,C:\path\to\jruby
). - Click "OK" to save the changes.
Add JRuby Bin Directory to PATH:
Add thebin
directory inside the JRuby installation directory to your system's PATH environment variable. This step ensures that you can run JRuby from any command prompt without specifying the full path.- In the "Environment Variables" window, find the "Path" variable in the "System Variables" section and click the "Edit" button.
- Click the "New" button and add the path to the JRuby
bin
directory (e.g.,C:\path\to\jruby\bin
). - Click "OK" to save the changes.
Open a New Command Prompt:
After setting the environment variables, close any existing command prompt windows and open a new one to ensure the changes take effect.Verify JRuby Installation:
To verify that JRuby is installed correctly, run the following command in the new command prompt:cssjruby --version
If the installation is successful, this command will display the version of JRuby installed.
Run JRuby Script:
Now, you can run JRuby scripts by invoking thejruby
command followed by the name of the script file:jruby your_script.rb
Replace
your_script.rb
with the actual name of your JRuby script.
By following these steps, you should be able to run JRuby successfully on your Windows 10 machine without encountering the "Could not find or load main class org.jruby.Main" error.