Run Java & C program on Android Tab

Android : Coding on the terminal

Sponsored

Terminal is a command-line interface where the user can give and execute text-based commands. Command Prompt (CMD) and PowerShell on Windows are some examples that will give an idea. It is not as widely used by the average user. In fact, such an interface is preferred only by more advanced users who want to get deep down into the basics of the working of the system and allows to get to the back end of a program.

Terminal IDE :

Terminal IDE is an expandable terminal application, with a full Java / C / C++ / HTML / Android development kit, that runs on your Android device. Yes, it is available for free.

It uses the command line, with many powerful and robust open-source applications, plus a custom ASCII on-screen ‘soft’ keyboard that works well (You must ENABLE it in your device’s main Keyboard Settings).. and also has an extensive generic external ‘hard’ keyboard key mapper. This way CTRL / ALT / ESC etc.. should all be accessible. The app runs without requiring any root user permission.

NOTE : This app cannot be installed onto the SD card because you do not get ‘Execute’ permissions on that mount. It must run in this app’s private memory on the device.

Running a C code :

1. Download and install Terminal IDE from Google Play store.

2. Run the app. You will be presented with a number of options. Click on Install System and follow on screen instructions.

3. Now tap on Terminal IDE. $ prompt opens.

4. To setup GCC, type ”  install_gcc ” without quotes and execute the command. This unpacks the GCC package.

5.  Navigate to system/src folder using cd  ( cd ~/system/src ) command and create a folder using command “mkdir myccode”. You may name the folder as per your desire. (here named myccode)

6. Create a source file, say test.c, using the command ” cat > test.c ” without quotes and execute it. Now you can type in the code. Try the classic “Hello world” to keep things simple.

7. Once you have finished typing the code, press volume(-) button + C (onscreen -keyboard) to terminate cat command.

8. To compile the code, use the command  ” terminal-gcc -c test.c ” without quotes.

9. If the code compiles without any errors, proceed to create the executable file using the command “ terminal-gcc test.o -o test ” without quotes.

10. Run the program using the command ” ./test ” to see the output.

Running a java code :

1. Open the terminal. Navigate to system/src folder using cd command and create a folder using command “mkdir myjavacode”. You may name the folder as per your desire. (here named myjavacode)

2. Create a source file hello.java using the command “cat > hello.java” without quotes and execute it. Now you can type in the code. Try the classic “Hello world” program to keep things simple.

public class hello {
public static void main(String[] zArgs) {
System.out.print(“Hello World”);
}
}

3. Once you have finished typing the code, press volume(-) button + C (onscreen -keyboard) to terminate cat command.

4. To compile the code, use the command  ” javac hello.java” without quotes. You will now have a file named hello.class in the same directory.

5. If the code compiles without any errors, proceed to create the executable file using the command “ dx –dex –output=hello.jar hello.class” without quotes.

6. Run the program using the command ” java -jar hello.jar hello ” to see the output.

Happy Coding !

Related Posts Plugin for WordPress, Blogger...

  • Suresh

    how to run c++
    wether i have to install g++

    if i get any errors how to go back the code and edit it.

  • Ratul

    Hi Thanks for this article.
    I had a doubt. Can we somehow use external java libraries with terminal ide? Like the ACM library?

    Thanks in advance 🙂