Jump to content
xisto Community
Sign in to follow this  
beeseven

Luajava Interpreted Java?

Recommended Posts

The difference between an interpreted language (like Python or BASIC) and a compiled language (like C or Java [...sort of]) is that whereas compiled programs must be completed and turned into a separate, runnable file before they are run, interpreted languages are looked at by the program that runs them line by line, and each line is executed as it is come to. (I say that Java is "sort of" a compiled language because it is compiled into byte code, which is then interpreted, as opposed to machine code like C, C++, and [i think] assembly). However, the makers of Lua (an interpreted language similar to Python) have made something that can execute Java code one line at a time (if you've used Python or Lua or another language like those, it's the same format).

 

You can find out more about it at the LuaJava page. You can download it from there (you also need Lua 5.0, it won't work with 5.1 for some reason) or I have a zip of what you need at http://forums.xisto.com/no_longer_exists/ (run luajava.bat, if you really don't trust me just open it in Notepad). You also need Java installed.

 

The code isn't exactly the same as Java, it's a little more relaxed and uses some syntax from other languages. For example, to make a JFrame (-- is a comment, var: is the same as var.):

frame = luajava.newInstance("javax.swing.JFrame","title")frame:setSize(300,300)frame:setLocation(0,0)panel = luajava.newInstance("javax.swing.JPanel")frame:setContentPane(panel)frame:setDefaultCloseOperation(3) --3 is the same as JFrame.EXIT_ON_CLOSE, I just use 3 because it's shorterframe:setVisible(true)
All the other commands you need to know (there are only a few) are at the LuaJava reference

Share this post


Link to post
Share on other sites

Since you all are obviously not as impressed as me, I'll post some simple things as I make them.

 

Posted Image

In this one, you click the button and it prints "hello" (I forgot to give the button text >_> )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.