# Create java IDE

**URL:** <https://forum.golangbridge.org/t/create-java-ide/6361>\
**Category:** Technical Discussion\
**Created:** [August 21, 2017, 10:15am UTC](https://forum.golangbridge.org/t/create-java-ide/6361 "2017-08-21T10:15:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mujtaba\_Ahmed](https://forum.golangbridge.org/letter_avatar_proxy/v4/letter/m/f08c70/32.png) [@Mujtaba\_Ahmed](https://forum.golangbridge.org/u/Mujtaba_Ahmed)\
**Post date:** [August 21, 2017, 10:15am UTC](https://forum.golangbridge.org/t/create-java-ide/6361/1 "2017-08-21T10:15:47Z")

</div>

Hi all

Is there a way to run a java code that was received to the server using ajax call from html. need to create an ide

It is **preferable** to run without creating any files

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/nobbz/32/3096_2.png) [@NobbZ](https://forum.golangbridge.org/u/NobbZ)\
**Post date:** [August 21, 2017, 10:34am UTC](https://forum.golangbridge.org/t/create-java-ide/6361/2 "2017-08-21T10:34:29Z")

</div>

Yes, but thats much harder than to do it with python, since Java needs to get compiled and enforces a certain layout of how files have to be organized.

My suggestion to not run arbitrary user supplied code does still hold.

Also I am not sure why you actually want to **run** arbitrary code written in language X for an IDE. Personally I do use IDEs to write, edit, view, and compile code. Not to run it. Perhaps I’d like to run tests, but therefore you usually do not run a sourcefile but rather a wrapping testrunner, which compiles, runs and formats the output.

---

<div class="post-metadata">

**Author:** ![Mujtaba\_Ahmed](https://forum.golangbridge.org/letter_avatar_proxy/v4/letter/m/f08c70/32.png) [@Mujtaba\_Ahmed](https://forum.golangbridge.org/u/Mujtaba_Ahmed)\
**Post date:** [August 21, 2017, 10:40am UTC](https://forum.golangbridge.org/t/create-java-ide/6361/3 "2017-08-21T10:40:48Z")

</div>

Well, our aim is to take java code as input from the user. Then, compile and run the code and send back to the user the output of the program.

How do you think I should run the java file at the server?

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/nobbz/32/3096_2.png) [@NobbZ](https://forum.golangbridge.org/u/NobbZ)\
**Post date:** [August 21, 2017, 10:59am UTC](https://forum.golangbridge.org/t/create-java-ide/6361/4 "2017-08-21T10:59:36Z")

</div>

If you do not seal up the running system correctly your user can access arbitrary files, get access to environment variables, etc.

Therefore I do assume, that at least running the compiled program will happen in a **sandbox** ed environment.

- Compile the file using `javac`. `javac` is not able to read from stdin, you will need to write out the file and run `javac` from a working directory relative to the file that fits Javas requirements of how to discover packages.
- use `jar` to create a package from the created `*.class` files.
- Transfer created `*.jar` to **sandbox**
- run it using `java -jar`

If you have no clue how to properly sandbox the execution, **do not** offer this as a service or ask for **professional** help! You can get into serious trouble if done wrong (or not at all)!

---

<div class="post-metadata">

**Author:** ![Mujtaba\_Ahmed](https://forum.golangbridge.org/letter_avatar_proxy/v4/letter/m/f08c70/32.png) [@Mujtaba\_Ahmed](https://forum.golangbridge.org/u/Mujtaba_Ahmed)\
**Post date:** [August 21, 2017, 11:06am UTC](https://forum.golangbridge.org/t/create-java-ide/6361/5 "2017-08-21T11:06:38Z")

</div>

Is there any way we can compile the java file without doing “ **javac File.java** ”. As far as I know there is no other way.

Also, I was able to send a json file to exec.Command(“python”, params.Get(“JSON FILE”)) and it worked perfectly. If there is a way to run java code without creating additional files, my work is easily done. Please let me know if there is a way to do that.

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/nobbz/32/3096_2.png) [@NobbZ](https://forum.golangbridge.org/u/NobbZ)\
**Post date:** [August 21, 2017, 11:36am UTC](https://forum.golangbridge.org/t/create-java-ide/6361/6 "2017-08-21T11:36:31Z")

</div>

As I said earlier, the java compiler needs a file, which has to be placed at a certain location relative to `javac`s working dir. You can not get around that limitation without writing your own java-compiler.

Also calling `python` with a JSON file makes absolutely no sense. The command you have shown, will run `python` and tell it to run the file that has the name as whatever gets returned by `params.Get("JSON FILE")`. If the returned value is in fact a stringified JSON-object, I doubt that you have a file which is named exactly like that.

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [November 19, 2017, 11:36am UTC](https://forum.golangbridge.org/t/create-java-ide/6361/7 "2017-11-19T11:36:31Z")

</div>

Closed on November 19, 2017, 11:36am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
