I've recently just discovered that there is something called ByteCode in Java, and I was wondering what it is used for.

I am trying to make a simple Typing Test Word Typer Bot, basically it reads the words on the browser for a typing test called 10FastFingers, then it types it in there. I was wondering if this is possible in Java ByteCode.

How can I learn Java Bytecode as a beginner? I've already looked at Oracle's video on ByteCode, and it says it is for dummies, but it is too hard to get a grasp on byte code from that video.


3 Years
Discussion Span
Last Post by JamesCherrill

Byte code is generated by the java compiler. It is the assemble style instructions your java code is turned into. Although a good programmer will understand the bytecode,should you ever need to review it, actually writing it is pretty inefficient.
This sample is from the wikipedia java byte code page
Java code:

for (int i = 2; i < 1000; i++) {
    for (int j = 2; j < i; j++) {
        if (i % j == 0)
            continue outer;
    System.out.println (i);


1:   istore_1
2:   iload_1
3:   sipush  1000
6:   if_icmpge       44
9:   iconst_2
10:  istore_2
11:  iload_2
12:  iload_1
13:  if_icmpge       31
16:  iload_1
17:  iload_2
18:  irem
19:  ifne    25
22:  goto    38
25:  iinc    2, 1
28:  goto    11
31:  getstatic       #84; // Field java/lang/System.out:Ljava/io/PrintStream;
34:  iload_1
35:  invokevirtual   #85; // Method java/io/PrintStream.println:(I)V
38:  iinc    1, 1
41:  goto    2
44:  return

Its pretty obvious which one I would rather type out and develop with.
In answer to your question, yes, your program can be written in bytecode because that is what compiled java is.
Apparently there are 198 bytecode instructions (from the wiki page above) so learning it and writing in it is possible but the real question is why would you want to?


Oh, I was thinking I needed bytecode injection do make my program (which basically reads the text on the browser and automatically types it in).


Can bytecode also be used to tap into other java processes and modify things on their run time?

Say I was playing a game like Mario, before Mario.jar starts up, could I possibly write a software that changes something in Mario.jar's execution. Say, change the speed of the enemies?

This is vital information needed for the program that I'll be attempting to make.

Thanks for sharing your knowledge


In real life nobody codes applications in bytecode. If you can't do something in Java then its very unlikely that you could do it in bytecode. Unless you plan a career in writing Java compilers or JVMs you will never write a single line of bytecode. The only time "normal" people ever see it is if they are desperate to optimise some terribly time-critical Java code, and even then the very next release of the compiler could invalidate their conclusions.

Executive Summary: Forget about bytecode

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.