Skip to content

Commit

Permalink
Fix java boilerplate bug
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonynmh committed Nov 6, 2023
1 parent 55d2481 commit 5c6e313
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions Execution/src/ExecutionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ const executeJava = async (req, res) => {
const compileProcess = spawn('javac', [javaFilename]);
const compileResult = await executeScript(javaFilename, compileProcess, false);

logger.logSuccess("Program compiled successfully.");
if (compileResult.includes('error')) {
logger.error('Compilation failed.');
res.json({ output: compileResult });
} else {
logger.logSuccess("Program compiled successfully.");

const javaProcess = spawn('java', [javaClassName]);
const result = await executeScript(javaClassName, javaProcess, true);
const javaProcess = spawn('java', [javaClassName]);
const result = await executeScript(javaClassName, javaProcess, true);

logger.logSuccess("Program executed successfully.");
logger.logSuccess("Program executed successfully.");

res.json({ output: result });
res.json({ output: result });
}
} catch (err) {
logger.log(err);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Collaboration/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class Main {
const handleLanguageChange = (e) => {
const selectedLanguage = e.target.value;
setLanguage(selectedLanguage);
if (language === Language.JAVA) {
if (selectedLanguage === Language.JAVA) {
setCode(javaBoilerplate);
}
sessionStorage.setItem(`codeEditorLanguage_${roomId}`, selectedLanguage); // Store the language in session storage
Expand Down

0 comments on commit 5c6e313

Please sign in to comment.