Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7901179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:09:21+00:00 2026-06-03T09:09:21+00:00

I want to be able to input java commands/code to execute during run-time (during

  • 0

I want to be able to input java commands/code to execute during run-time (during the execution of a “persistent” program) in the same way, or as close as possible, to the same code would be executed if it was present on the source-code for the program (programmed as part of the software), using a GUI element, like jTextArea.


The following StackOverflow questions seem to be related, but, along with they’r answers, don’t seem to be what i’m looking for.

How To Get Input From Console Class In Java?

Using GUI for console input and outputin java

I don’t want to “be able to trigger actions from specific console inputs, and print the feedback into the console”, as seems to be the case of console applications described in those question and answers.

What i want is to “be able to execute actual java code, that i cannot predict nor control, from console (or GUI) input”.

NOTE: The “i cannot predict nor control” here refers to the “developer”…But of course i can predict and “control” it if i’m the one inputting the code, as the “user” would do.


Since java uses a virtual-machine environment, i think it might be possible for it to execute “run-time inputted code”…But i’m not sure such thing is even possible.

For example, i’d like the run-time input of for(int i=0; i<3; i++){System.out.println(i);} in the “GUI console” (jTextArea, for example) to, upon pressing the enter key or clicking a “Send” button, be (“compiled and “?) executed, and give the same output as if it was part of the original source-code, thus:

0
1
2

So i’d like to know the following:

  • Is it possible?
  • If yes, how can i do it? (OR, if no, what is the closest alternative?)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:09:22+00:00Added an answer on June 3, 2026 at 9:09 am

    Use the JavaCompiler. It can compile code from a String.

    For an E.G. see the STBC & especially the source code. It provides a GUI and can compile the code in the text area on button click.

    STBC GUI

    But note the:

    System Requirements

    STBC will run on any computer with a version 1.6+ Java Plug-In* JDK (AKA SDK).

    (*) The API that STBC uses is merely a public interface to the compiler in the tools.jar that is distributed only with JDKs (though the ‘public JRE’ of the JDK also seems to acquire a tools.jar). This leads to some unusual requirements in running either the native jar, or the web start app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a java code to read the input XML file and
Finally i am able to run super user commands in android program. Now i
I'm new to Java. I want to be able to input operational characters in
I want to facilate my client to run java program through UNIX command prompt
In my Rails app I want users to be able to input video links
I'm making a Sudoku program in java to learn some algorithms so I want
I'm writing Java on Windows 7, and I want to be able to work
Dear all I want to execute a EXE file in Java, but I was
I'm writing a game in Java, and I want the user to be able
I'm looking to tokenize Java/Javascript-like expressions in Javascript code. My input will be a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.