Jump to content

[1.15] Compile a java code stored in a String


MikeyJY

Recommended Posts

Hi. Does anyone know how to compile a string and get the output as a string?

I'm trying to make an programming mod for in-game java programming. An gui that acts as a "IDE":

image.thumb.png.c0aa9702fb17ec17d639c774c9a3c7e9.png

But I need to compile the code written by player. I have this string made by user in-game:

String code = "class JavaMod{ public static void main(String args[]){ System.out.println(\"Text\"); } }";

I need to compile the string, get the output in a "String output", (in this case the value should be "Text"), and show in-game GUI;

Of course for the player to play this mod will require JDK configured with bin path in control panel enviorment variables, because I need the actual Java Virtual Machine on player's PC for the code to be compiled, no?

 

 

Edited by MikeyJY
Link to comment
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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.