Java Command Line? [duplicate] - java

This question already exists:
Closed 12 years ago.
Possible Duplicate:
Java REPL shell
Hey,
Is there any way to execute Java code (as you type) on a command line?
For instance, something like this
(command line)
java
import ARDrone;
ARDrone drone = new ARDrone(null, null, null);
drone.takeoff();
(so that you can enter lines of code in the command line)

Groovy can do that. It's possible with java syntax and groovy syntax.
You can try at Groovy web console. You have also groovy console and groovy shell.

You are looking for an interpreter.
Google tells me that BeanShell appears to be one, although I don't know Java and have never heard of BeanShell.

Related

Is there a java program that can get java syntax from the user and convert it as an output, kinda like mini IDE?

I was wondering if I can make a java program that can act as Java IDE which will take syntax from user and execute it in the terminal. If there is, what are the syntax used to manipulate the compiler and syntax for executing the syntax? Your answers would be helpful.

Calling java from shellscript with parameters [duplicate]

This question already has answers here:
Propagate all arguments in a Bash shell script
(12 answers)
Closed 3 years ago.
From a shell script, I would like to call a shell script which calls a java program. The parameters to the java program are passed from the first shell script.
shellscript1 --> shellscript2 (set par1) --> Java par1
I have tried to source shellscript2 in shellscript1. Still couldnt pass parameters. I dont want to export the parameters and call shellscript2
Any ideas appreciated
Do not use shellscript 2 but add the param to shellscript 1. Using 2 shellscripts makes it complex.

How to call python script form java class [duplicate]

This question already has answers here:
Calling Python in Java?
(12 answers)
Closed 8 years ago.
I have a java web app where i need to use a simple web crawler to read html from webpages. I could not find any simple solution for this in java. But got a very simple python script that solve my problem. Now how to call that python script (.py) from my java class and also get the returned value from the python script .Thanks in advance .
First check out Calling Python in Java?
Another approach might be to call the python interpreter from the command line with a Java Process. See Java Process with Input/Output Stream and Call python script within java code (runtime.exec)

How can I interact java program using python [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How to execute java program using python considering inputs and outputs both
I want my python variable should receive all the output of java program and using that variable i will display the output on the screen. also if there is a input to java program, I want that user will enter the input which will be stored in my python variable and using this variable, I want to pass the input to java program.. What should I do?? Please help..
Consider using Jython instead, it was designed with Python-Java interoperability in mind. Alternatively, use the standard input/output facilities of the operating system for writing strings back and forth between the two programs, take a look at this post.

How to implement a built in compiler in Java/Swing?

I'm writing a text/code editing program for my own use in Java/Swing, and was wondering how I would go about setting up a built-in C compiler inside it. I would likely use GCC or TCC as the compiler. Anyway, my question is- how would I actually implement the compiler? Would I use a library that gives Java access to command line commands? Are there such libraries and if so, which is the best/easiest to use?
Thanks.
Accessing command line is the easiest way.
Try something like this:
Process myProc = Runtime.getRuntime().exec(command);
Where command is some string you want to pass to the command line.
After that you can redirect output / input of that process to the some java buffers to have the full control.
myProc.getInputStream();
myProc.getOutputStream();
Typically IDE/Editor's don't implement the compilers. They will just execute the commands and pass the filename as argument (along with other necessary files). They also pipe/stream the output to a separate window/pane in the editor. So you need to integrate the compiler somehow not implement one. You can execute the commands in java using Runtime class. Start here.

Categories