1

I've been learning Ruby and if I understand correctly, I can get my Ruby scripts, and use JRuby to create Java class files, essentially allowing my Ruby scripts to be run in the JVM. I have successfully managed to create a .class file from my Ruby script.

I would like to know, is it possible to make this class file into an executable file? Am I supposed to use Warble or Rawr to do this? I installed the Warble GEM but I couldn't work out how to use it and I'm not sure if it's even what I need... What's the easiest way?

Jean-Luc
  • 3,563
  • 8
  • 40
  • 78

1 Answers1

3

Type this in the command line:

cd C:/Users/Someone/Path/To/Class/
jar cvfm executable.jar manifest.mf Foo.class

Where manifest.mf is something like

Main-Class: Foo

Change C:/Users/Someone/Path/To/Class/ to the path to your files and change Foo to the name of your class. This will create a jar file called "executable.jar."

tckmn
  • 57,719
  • 27
  • 114
  • 156
  • Okay so I did what you wrote; I ran `jar cvfm executable.jar manifest.mf HelloWorld.class`. That created a file called `executable.jar`. I then attempted to run my jar file using the command `java -jar executable.jar` but that didn't work: `no main manifest attribute, in executable.jar`. I don't know why it would say this because I created a `manifest.mf` and put the line `Main-Class: HelloWorld` in it. Am I supposed to put something else? – Jean-Luc Dec 01 '12 at 03:55
  • 1
    @user968243 try putting two blank lines, like `Main-Class: HelloWorld(enter)(enter)`. Also, make sure your `.class` and `.mf` are in the same directory. Also make sure that your manifest is called "manifest.mf" and not "manifest.mf.txt." – tckmn Dec 01 '12 at 04:04
  • Okay, the enter enter thing works (seems a bit silly, but hey, if it works)! Anyway, I have another error now, when I go to run it, I get `Exception in thread "main" java.lang.NoClassDefFoundError` and that's fulled by a whole heap of lines beginning with `at java...`. Advice appreciated, thanks! – Jean-Luc Dec 01 '12 at 06:29
  • @user968243 If you are running it from the command prompt, you have to do this: http://stackoverflow.com/questions/6334148/exception-in-thread-main-java-lang-noclassdeffounderror . It should work fine when double-clicking it. – tckmn Dec 01 '12 at 13:19