Merge pull request #748 from Shaswat0312/feature/Code-Editor · javaistic/javaistic@fe39042 · GitHub
Skip to content

Commit fe39042

Browse files
authored
Merge pull request #748 from Shaswat0312/feature/Code-Editor
Add Java IDE to website
2 parents fa73b4a + 38cccd7 commit fe39042

8 files changed

Lines changed: 381 additions & 6 deletions

File tree

bun.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions

src/app/api/playground/route.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// src/app/api/run-java/route.ts
2+
3+
import { NextResponse } from 'next/server';
4+
5+
export async function POST(req: Request) {
6+
try {
7+
const { code } = await req.json();
8+
9+
const response = await fetch('https://api.jdoodle.com/v1/execute', {
10+
method: 'POST',
11+
headers: {
12+
'Content-Type': 'application/json',
13+
},
14+
body: JSON.stringify({
15+
script: code,
16+
language: 'java',
17+
versionIndex: '3', // Java 11
18+
clientId: '' ,// ← replace with your actual clientId
19+
clientSecret: '', // ← replace with your actual clientSecret
20+
}),
21+
});
22+
23+
const data = await response.json();
24+
25+
return new NextResponse(JSON.stringify({
26+
run: {
27+
output: data.output || 'No output',
28+
},
29+
}), {
30+
status: 200,
31+
headers: { 'Content-Type': 'application/json' },
32+
});
33+
34+
} catch (err) {
35+
console.error(err);
36+
return new NextResponse(JSON.stringify({ error: 'Execution failed' }), {
37+
status: 500,
38+
headers: { 'Content-Type': 'application/json' },
39+
});
40+
}
41+
}

src/app/layout.config.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export const baseOptions: BaseLayoutProps = {
2929
text: "Sponsors",
3030
url: "/sponsors",
3131
},
32+
{
33+
text: "Playground",
34+
url: "/playground",
35+
}
3236
],
3337
githubUrl: "https://github.com/javaistic/javaistic",
3438
themeSwitch: {

src/app/playground/layout.tsx

Lines changed: 17 additions & 0 deletions

0 commit comments

Comments
 (0)