Call Java function inside Lua

Simple QUESTION : Are there ways to run or load java functions inside Lua?

Loading Lua functions inside Java is possible using LuaJ. I wonder if loading Java functions inside Lua file is possible too.

I am trying to create a phone application that transfers files between server and client using Lua. The server uses Java while client uses Lua.

Why I want to run Java functions inside Lua?
Because I cannot decode bytes created Java to Lua, unless the bytes converted are pure string or number. Moreover, the chunks sent by the server are encapsulated in a class like this:

   

 public class FileChunk { private List\<Data\> dataList; private byte[] fileData; //functions below } // then UDPServer.java sends bytes of FileChunk to Client

Because of this, packets received by the lua function are strange. So I want to run java helper files (eg. UDPClient.java) in order to receive and decipher the chunks, instead of lua.  

I don’t want to change the server nor migrate the client language to java. I haven’t found any resources about this so I need help.

No, you cannot run Java, C, C++, C #, Objective C, Swift, Javascript, or any other language inside of Lua.  With Corona SDK you cannot even link in libraries of code built in those languages. Lua is all you have. That said, Corona Enterprise and CoronaCards allow your Lua code to access code written in native languages. You could use Enterprise for instance to take that packet and convert it into a string and pass it to Lua to operate on.

We also have a “bit” plugin that lets you do bitwise math which might help and of course the string.byte() function will give you numeric values from each byte of a string. This honestly should be sufficient to process most server byte packed blocks of data.

https://docs.coronalabs.com/api/library/string/byte.html

You might have to do some math to assembly a 4 byte long or a 2 byte short from 2 or 4 numbers:

highByte, lowByte = string.byte(data,1,2) shortValue = highByte \* 256 + lowByte

or something similar.

No, you cannot run Java, C, C++, C #, Objective C, Swift, Javascript, or any other language inside of Lua.  With Corona SDK you cannot even link in libraries of code built in those languages. Lua is all you have. That said, Corona Enterprise and CoronaCards allow your Lua code to access code written in native languages. You could use Enterprise for instance to take that packet and convert it into a string and pass it to Lua to operate on.

We also have a “bit” plugin that lets you do bitwise math which might help and of course the string.byte() function will give you numeric values from each byte of a string. This honestly should be sufficient to process most server byte packed blocks of data.

https://docs.coronalabs.com/api/library/string/byte.html

You might have to do some math to assembly a 4 byte long or a 2 byte short from 2 or 4 numbers:

highByte, lowByte = string.byte(data,1,2) shortValue = highByte \* 256 + lowByte

or something similar.