Skip to content

Commit 8373adf

Browse files
committed
New tutorial
1 parent 0dbd09f commit 8373adf

3 files changed

Lines changed: 133 additions & 1 deletion

File tree

.vitepress/config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ export default defineConfig({
250250
{
251251
text: "Command Palette",
252252
link: "/tutorials/command-palette"
253+
},
254+
{
255+
text: "How to run java",
256+
link: "/tutorials/how-to-run-java"
253257
}
254258
]
255259
},

cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
],
99
"dictionaryDefinitions": [],
1010
"dictionaries": ["en"],
11-
"ignoreWords": ["Acode", "Ace", "plugin", "npm", "preconfigured", "Termux", "onsave", "onhide", "sidenav", "rgba", "mymode", "extname"],
11+
"ignoreWords": ["Acode", "Ace", "plugin", "npm", "preconfigured", "Termux", "onsave", "onhide", "sidenav", "rgba", "mymode", "extname", "acodex", "javac"],
1212
"allowCompoundWords": false
1313
}

tutorials/how-to-run-java.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
head:
3+
- - meta
4+
- name: How to run Java Code on Android - Acode
5+
content: Run java code using the termux and acode on Android
6+
- - meta
7+
- name: keywords
8+
content: termux run java on Android acode acodex
9+
---
10+
11+
# How to Run Java on Acode Using Termux
12+
13+
If you want to code in Java on **Acode Editor** (assuming you already have it installed), you'll need **Termux**, a Linux terminal emulator for Android. This guide will walk you through the entire setup process, step-by-step.
14+
15+
### Prerequisites
16+
- **Acode Editor** installed on your Android device.
17+
- **Termux**, a terminal emulator for running Linux on Android.
18+
19+
## Step 1: Install Termux via F-Droid
20+
21+
To get started with Termux, you need to install **F-Droid**:
22+
23+
1. **Download and Install F-Droid**:
24+
- Search for "F-Droid" on your preferred search engine or visit the [F-Droid website](https://f-droid.org/) and download the APK.
25+
- Install F-Droid on your device.
26+
27+
2. **Install Termux**:
28+
- install the downloaded termux apk
29+
30+
## Step 2: Setup Termux
31+
32+
After installing Termux, follow these steps to set it up:
33+
34+
1. **Launch Termux for the First Time**:
35+
- Open Termux and allow it to set up the environment automatically.
36+
37+
2. **Grant Storage Access to Termux**:
38+
- Run the following command to allow Termux to access your device’s storage:
39+
```sh
40+
termux-setup-storage
41+
```
42+
43+
3. **Update Termux Package Repositories and Installed Packages**:
44+
- Ensure that Termux is up to date by running the following command:
45+
```sh
46+
pkg update && pkg upgrade -y
47+
```
48+
49+
4. **Install Java (OpenJDK 17)**:
50+
- Install the Java Development Kit (JDK) by running:
51+
```sh
52+
pkg install openjdk-17
53+
```
54+
55+
56+
::: info
57+
Skip step 3 , if you want don't want to run java code from Acode
58+
:::
59+
60+
61+
## Step 3: Configure Acode with Terminal Integration
62+
63+
Now that Termux is set up, you can integrate Acode with Termux for running Java.
64+
65+
1. **Open Acode Editor**:
66+
- Launch **Acode Editor** on your device.
67+
68+
2. **Install the AcodeX Plugin(you can choose any other terminal plugin)**:
69+
- Click the three dots in the top-right corner.
70+
- Go to **Settings** » **Plugins**.
71+
- Switch to the **All** tab and install the plugin called **AcodeX - Terminal**.
72+
73+
3. **Install AcodeX Server on Termux**:
74+
- Open Termux and install the AcodeX server by running the following command:
75+
```sh
76+
curl -sL https://raw.githubusercontent.com/bajrangCoder/acode-plugin-acodex/main/installServer.sh | bash
77+
```
78+
79+
4. **Launch the AcodeX Terminal Server**:
80+
- To start the AcodeX terminal server, run:
81+
```sh
82+
acodex-server
83+
```
84+
- Alternatively, you can use the shorter alias:
85+
```sh
86+
axs
87+
```
88+
- To stop the server, use `CTRL + C`.
89+
90+
## Step 4: Link Your Java Projects with Acode
91+
92+
Once everything is set up, follow these steps to open your Java projects in Acode:
93+
94+
1. **Ensure Your Project Resides in the Termux Storage**:
95+
- Ensure that your Java project is stored within the Termux accessible filesystem, such as Termux home dir or internal storage or other locations accessible from Termux.
96+
97+
2. **Start the AcodeX Server on Termux**:
98+
- Ensure the terminal server is running by executing `acodex-server` in Termux.
99+
100+
3. **Add Your Project Folder to Acode**:
101+
- In Acode, click the three dots, then go to **Files**.
102+
- Use the **Add Path** (or **+**) button to add Termux paths.
103+
- Navigate to your Java project folder, select it, and click the **✔** button at the bottom-right corner to add it to the projects sidebar.
104+
105+
4. **Open Your Java Project's Main File**:
106+
- Navigate to the Java project file you want to work on and open it in Acode.
107+
108+
## Step 5: Compile and Run Java in Acode
109+
110+
Now, you can compile and run your Java code directly in Acode using the terminal.
111+
112+
1. **Open the Terminal**:
113+
- In Acode, press `CTRL + K` to open the terminal.
114+
115+
2. **Navigate to Your Project Folder**:
116+
- In the terminal, use the **folder icon** to navigate to your Java project’s directory.
117+
118+
3. **Compile and Run Your Java Code**:
119+
- To compile your Java file, run the following command:
120+
```sh
121+
javac YourFileName.java
122+
```
123+
- After compiling, run the Java program:
124+
```sh
125+
java YourFileName
126+
```
127+
128+
By following these steps, you can successfully run and manage Java projects directly on your Android device using Acode and Termux. Happy coding!

0 commit comments

Comments
 (0)