In some Java IDEs (BlueJ and DrJava, for example), the user can open an interaction window where Java expressions and statements can be typed in. The IDE quickly compiles and runs the code, displaying the returned value if 开发者_StackOverflow社区necessary.
In BlueJ, it's called the Code Pad. It's similar in spirit to the Interaction Pane in DrRacket/DrScheme.
Does something like this exist for Eclipse?
You may be looking for Scrapbook pages. Here's a write-up and here are other SO questions which talk about it.
There is also the Display View, which allows executing code while debugging. It's handy, because it evaluates in the context of the current stack frame.
I know this is a pretty big necro, but I came upon this page while searching for the answer myself. Unfortunately, none of the above answers led me to figuring out how to do what I wanted easily. I found out how to do what I wanted to and decided to post here incase someone else learning Java got stuck the same way we did.
The 'Interactions Panel' in DrJava for i.e. allows you to write 'run programName 1 2 3' and 1 2 3 are the inputs for args[0]->args[2] and the program will then be ran.
To do this easily in Eclipse, click on the Run tab -> Run Configurations... -> Arguments tab -> Program Arguments -> type '1 2 3'. This will run your program with 1 2 3 as your inputs for your arguments.
Cheers.
精彩评论