I'm looking to write a short program (maybe a Hello World) in Java bytecode. I just want to write the bytecode using my text editor and run it. How would I do this? Got an example? Thanks!
You could try Jasmin!
You compile it using: > java -jar jasmin.jar hello.j And then you run it like any class: > java HelloWorld Hello World. Update I see that your question mentions "without using Javac or Java". Could you clarify how you meant that statement? |
|||||||||||||
|
|
|||
|
Maybe this article can get you started: Bytecode basics (a little old, but you will get the idea). The class file format will come in handy too :D |
||||
|
Byte code is written as actual bytes, which are not normally easily editable by a normal text editor. This means you will need something that converts a textual representation to binary. A reasonable place to start would be an assembler like Jasmin. http://en.wikipedia.org/wiki/Jasmin_(Java_assembler) |
|||
|
I've created a new Java bytecode assembler that is backwards compatible with Jasmin but also adds lots of new features and simplifies the syntax slightly. Here's an example of how you might write a Hello World program.
I've also written a tutorial on bytecode assembly. It currently only covers Hello, World, but I can continue it if there is interest. |
||||
|