Skip to content

Fix JRuby Java extension build on Windows #825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ desc "Generate parser with ragel"
task :ragel => [JAVA_PARSER_SRC]

if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
path_separator = File::PATH_SEPARATOR
ENV['JAVA_HOME'] ||= [
'/usr/local/java/jdk',
'/usr/lib/jvm/java-6-openjdk',
'/Library/Java/Home',
].find { |c| File.directory?(c) }
if ENV['JAVA_HOME']
warn " *** JAVA_HOME is set to #{ENV['JAVA_HOME'].inspect}"
ENV['PATH'] = ENV['PATH'].split(/:/).unshift(java_path = "#{ENV['JAVA_HOME']}/bin") * ':'
ENV['PATH'] = ENV['PATH'].split(/path_separator/).unshift(java_path = "#{ENV['JAVA_HOME']}/bin") * path_separator
warn " *** java binaries are assumed to be in #{java_path.inspect}"
else
warn " *** JAVA_HOME was not set or could not be guessed!"
Expand All @@ -65,7 +66,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
JRUBY_JAR = File.join(CONFIG["libdir"], "jruby.jar")
if File.exist?(JRUBY_JAR)
JAVA_SOURCES.each do |src|
classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * path_separator
obj = src.sub(/\.java\Z/, '.class')
file obj => src do
sh 'javac', '-classpath', classpath, '-source', '1.8', '-target', '1.8', src
Expand Down