Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Introduction to Java

Recommended Posts

Introduction to Java


This is a brief introduction to the Java programming language, which we use to write scripts. No previous experience or knowledge is required, as this guide was written for beginners that are just starting out.


After reading this introductory guide, everything that you need in order to get started can be found on the Oracle website. It's completely free, and it's one of the best places online where you can learn Java:






What is a programming language?

A programming language is a tool that allows us to easily create computer programs.

A computer program is a sequence of instructions that is selectively executed by the computer. Any computer games that you've ever played (RuneScape included), are all computer programs.




How can a computer understand a programming language?

It can't.

A computer is an electronic device capable of executing "machine code" - what we numerically represent as 0s and 1s, but at the hardware level, there are no such digits, but instead patterns of HIGH (1) and LOW (0) voltage electrical charges.


Every line of code that we write in any kind of programming language needs to be transformed into machine code before it can be executed, in one way or another. This is usually achieved by the processes of "compilation", "interpretation", or in some cases *Java* a combination of both.



Different types of programming languages

Java is just one of the many programming languages in existence, and in fact, it's one of the most popular ones (if not the most popular).

There are many ways to split programming languages into different categories. One of the fundamental characteristics of a language is the level of abstraction to the processor's instruction set architecture. "Low level" languages closely resemble the computer's native instruction set, they are said to be "closer to the hardware". "High level" languages have strong abstractions from the instruction set, and are much more easy to understand by humans, as they resemble English more closely.

High level languages have the advantage that every line of their code is translated to hundreds, thousands or even tens or thousands of lines of binary code, thus allowing us to write incredibly complex computer programs consisting of millions of instruction, by simply writing a few lines of high-level code.

For the reason mentioned above, the overwhelming majority of programmers are working with high level languages.





Java is a high-level, object-oriented, cross-platform programming language that has automatic memory management.


High level

Explained in the previous section. Basically means that it has strong abstraction from the hardware's architecture and resembles natural language.


Object oriented

Programming paradigm based on the concept of "objects": bundles of state (values, attributes) and related behavior (represented by methods). [Example: a Dog object might have the attributes: name, age, speed, color, breed etc. and the behaviors: eat, bark, run etc.]


Cross platform

Java source code (.java) is compiled to Java bytecode (.class), which can be executed by the Java Virtual Machine. This means that any computer that has a Java Runtime Environment installed is capable of executing the Java program, regardless of the underlying hardware or Operating System.


Automatic memory management

Java has a garbage collector that automatically frees up the memory periodically.





Program Execution

A computer's main and only task is to compute data. This consists of four different parts:

  • Input (of data)
  • Output (of data)
  • Processing data - done by the processor (CPU)
  • Memory: Storing the processed data, and retrieving data to be processed. - done by the working/main memory (RAM)




I would define data as the programmatic representation of information.

As stated above, a computer needs to be able to represent and manipulate data. In Java, data is represented by two different types: primitive and reference data types. The former are the simple, low-level building blocks used to create the latter, and they have special keywords reserved:


  • byte
  • char
  • short
  • int
  • long

Floating point:

  • float
  • double


  • boolean




Methods are executable portions of code that compute and transform the data, and can be invoked by the program while it's running.

They can be given data directly, through arguments, at the time of the invocation, or they can read the data stored in a variable. After processing, the result can be returned directly to the code that invoked the method, or it could be stored in a variable.



Classes and Interfaces

All your Java code, data and methods alike, need to be contained within Classes or Interfaces.

  • A class is a blueprint for creating software objects.
  • An interface is a group of related methods that classes can implement.


A software object is a bundle of state and behavior.

For instance, a 'Dog' object's state might consist of the attributes age, name, weight, maximum speed, while the Dog object's behavior would be defined by methods such as bark(), run(), eat() etc.

When a new object is created from a class, it's said that the class has  been "instantiated", and the object is a concrete "instance" of the class.





The end

This was a brief introduction to the Java programming language. Many more things could have been explained, but this guide would no longer qualify as a "brief introduction".

It's highly recommended to gain a solid understanding of Java before attempting to script, and one of the best places where you could do that, completely free, is on the Oracle website:



Programming is hard to learn, but nothing is truly impossible if you are persistent in achieving your goals - and this doesn't apply only to programming.


Good luck.


Edited by Einstein
  • Like 3

Share this post

Link to post
Share on other sites
2 minutes ago, AliveInMe said:

Hello. I come from another scripting forum. I'm currently looking into scripting for TriBot and was wondering why in the run() function there is an infinite while loop?

I'll be taking a look at your other tutorials soon.

TRiBot scripts only have their run method called once so a loop is needed for the script to continuously run. An infinite loop is used when you do not wish for the script to stop by its own means .Pressing 'Stop Script' on the client kills the script thread forcing it to stop.

Share this post

Link to post
Share on other sites
2 hours ago, Encoded said:

TRiBot scripts only have their run method called once so a loop is needed for the script to continuously run. An infinite loop is used when you do not wish for the script to stop by its own means .Pressing 'Stop Script' on the client kills the script thread forcing it to stop.

Interesting. I'm going to learn a bit more about the API and such before I get into it. Thanks for your reply

Share this post

Link to post
Share on other sites
On 12/8/2017 at 11:33 AM, Einstein said:

Also, when script kiddies are trying to impress someone, assembly is often the language of choice.


OP in that thread is referring to the bytecode manipulation library ASM, not the language. It sounds like he's using the right tool for the job. Not exactly skiddie behavior.

Edited by deus-x

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Our picks

    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)

      Improve banking API (Thanks @Encoded)

      Adds methods for returning and using Java Lists, rather than arrays

      Slightly randomizes some hardcoded behaviour

      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable

      Other back-end improvements

      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 61 replies
    • This release will:

      Add new internal framework for capturing exceptions

      Fix issue with not selecting the last column in world hopper (Thanks @Todd)

      Add a message about pin usage in Banking#openBank (Thanks @Todd)

      Disable the firewall by default (Thanks @Todd)

      Fix handling of the welcome screen after login (Thanks @Encoded)

      Fix wrong amount bank withdrawal (Thanks @Encoded)

      Fix Screen#isInViewport

      Fix Game#isInViewport (Thanks @Encoded)

      Call onBreakEnd for ListenerManager Breaking Listeners (Thanks @Encoded)

      Fix Prayer#getPrayerPoints NumberFormatException (Thanks @JoeDezzy1)

      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Thanks
        • Like
      • 28 replies
    • This release will:

      Fix LG for both OSBuddy and RuneLite

      Fix issue where the resizable client isn't able to be made smaller (Thanks @JoeDezzy1)

      Fix detection of the logout game tab when resizable mode and side panels are enabled (Thanks @JoeDezzy1)

      Add initial support for Sentry to allow us to identify and easily debug exceptions happening with all TRiBot users

      Add methods to determine if the bank is actually loaded, and not just the overarching interface (Thanks @wastedbro)

      Upcoming updates:

      Improved CLI support

      Full Sentry support

      Much more
        • Like
      • 64 replies
    • This release will:

      Fix NPE in Camera API (Thanks @wastedbro)

      Update deposit box interface ids (Thanks @Encoded)

      Add various bank methods (Thanks @wastedbro)




      Fix resizeable minimap bug (Thanks @wastedbro)

      Remove Java 8 requirement

      Please note: TRiBot is not yet fully compatible with Java 10+

      Fix the break handler issues by ensuring the break handler thread never gets paused

      Fix broken settings hooks

      Upcoming updates:

      Improved CLI support

      Much more

      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 68 replies
    • This release will:

      Add support for using custom F key bindings to switch between game tabs (Thanks @erickho123)

      Fix tab opening for "Skills" and "Kourend Tasks" (Thanks @erickho123)

      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 34 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...