mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-12 11:52:01 +01:00
69ad365b46
git-svn-id: file:///home/svn/framework3/trunk@8308 4d416f70-5f16-0410-b530-b9f4589650da
43 lines
1.2 KiB
Ruby
Executable File
43 lines
1.2 KiB
Ruby
Executable File
#!/usr/bin/ruby
|
|
|
|
require 'rubygems'
|
|
require 'rjb'
|
|
|
|
#Rjb::load('.', jvmargs=[])
|
|
Rjb::load("#{ENV['JAVA_HOME']}/lib/tools.jar:.",jvmargs=[])
|
|
|
|
clsJavaCompile = Rjb::import('javaCompile.CompileSourceInMemory')
|
|
clsCreateJar = Rjb::import('javaCompile.CreateJarFile')
|
|
clsFile = Rjb::import('java.io.File')
|
|
system = Rjb::import('java.lang.System')
|
|
#clsString = Rjb::import('java.lang.String')
|
|
|
|
classNames = [ "HelloWorld1", "HelloWorld2" ]
|
|
|
|
codez = Array.new
|
|
|
|
classNames.each { |name|
|
|
codez << %Q^
|
|
public class #{name} {
|
|
public static void main(String args[]) {
|
|
System.out.println("This is from #{name}.");
|
|
}
|
|
}^}
|
|
|
|
#compileOpts = [""]
|
|
#outputDir = system.getProperty('java.io.tmpdir')
|
|
outputDir = "testoutdir"
|
|
compileOpts = [ "-target", "1.3", "-source", "1.3", "-d", outputDir ]
|
|
|
|
success = clsJavaCompile._invoke('CompileFromMemory','[Ljava.lang.String;[Ljava.lang.String;[Ljava.lang.String;', classNames, codez, compileOpts)
|
|
|
|
fileOutJar = clsFile.new_with_sig('Ljava.lang.String;', 'output.jar')
|
|
filesIn = Array.new
|
|
|
|
classNames.each { |name|
|
|
filesIn << clsFile.new_with_sig('Ljava.lang.String;', "#{outputDir}/#{name}.class")
|
|
}
|
|
|
|
clsCreateJar._invoke('createJarArchive', 'Ljava.io.File;[Ljava.io.File;', fileOutJar, filesIn)
|
|
|