Wednesday 6 July 2016

Run programs directly from your Blog or Website

Update 2022: JDoodle provides 4 options to include IDE to a blog/website. This article just covers one of them. Please refer JDoodle Documentation for more details.
How nice it would be if the programs in your website/blog is directly executable without copying to an editor. Yes now it is possible with

JDoodle is an online compiler and editor for Java, C, C++ and many more languages, now using JDoodle you can make the programs in your website executable for around 76+ languages supported by JDoodle. Below is a sample program which you can execute from this blog itself.

Below is an another Java Program where you can pass Input Parameters to the program

Below is an another Java Program where you can pass Standard Input (STDIN) inputs to the program

Including executable programs into your website/blog is easy

  • Goto
  • Sign-in, if you don't have an account create one, it just takes a minute.
  • select the language in which you want to write program
  • create a program
  • save the program
  • click on Others --> Share/Embed
  • copy embed url 
  • Goto your website insert the copied url in a div as follows
    • <div data-pym-src=""></div>
  • include the below at bottom  of the Blog Post or Website
    • <script src="" type="text/javascript"></script>

By Default embed url will display the stdin (for all languages) and arguments (java only) input boxes, they can be disabled by passing following parameters

stdin=0 (hide stdin box), arg=0 (hide argument box), changing from 0 to 1 will display the boxes.
To make the plugin writeable use rw=1 parameter in the url
To set default values for arguments use "set_args" parameter.
Alternatively you can access your shared programs in 3 different plain format (xml, json, text) by just adding format parameter at the end of your shared url. Below are some examples

Alternatively if you want to redirect your user to JDoodle with the code snippet you want, you can just post your code to JDoodle as follows

<form action="" method="post">
  Script: <textarea name="initScript" rows="8" cols="80"></textarea>
  <input type="submit" value="Submit">

Just replace "/online-java-compiler" with the compiler url you want to redirect to. For example if you want to redirect to C compiler use -  ""

Please contact JDoodle and inform if you are embedding code in your site, so that they can update regarding embed functionality in advance if any.

if you are using Wordpress, there is a nice plugin you can use - JDoodle Plugin for WordPressPlease note: This wordpress plugin is 3rd Party Plugin, Thanks to Vikor for developing this, JDoodle is not responsible for this plugin in anyway including content, function, update and maintenance.