add java language

This commit is contained in:
MeiK 2020-10-30 15:06:09 +08:00
parent f3cb70019b
commit 37e3017ff7
4 changed files with 6 additions and 2 deletions

View File

@ -20,7 +20,7 @@ RUN apt install -y gcc g++
# install python3.8
RUN apt install -y software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt install -y python3.8
apt install -y python3.8 python3-pip
# install rust
RUN apt install -y curl && \

View File

@ -24,6 +24,7 @@ enum Language {
Node = 4;
TypeScript = 5;
Go = 6;
Java = 7;
}
enum JudgeType {

View File

@ -44,6 +44,7 @@ pub async fn judger(
Some(Language::Node) => "node main.js",
Some(Language::TypeScript) => "node main.js",
Some(Language::Go) => "./a.out",
Some(Language::Java) => "Main.java",
None => return Err(Error::LanguageNotFound(request.language)),
};
let process = Process::new(
@ -109,6 +110,7 @@ pub async fn compile(
Some(Language::Node) => "main.js",
Some(Language::TypeScript) => "main.ts",
Some(Language::Go) => "main.go",
Some(Language::Java) => "Main.java",
None => return Err(Error::LanguageNotFound(request.language)),
};
if let Err(e) = fs::write(path.join(filename), &data.code).await {
@ -124,6 +126,7 @@ pub async fn compile(
Some(Language::Node) => "/usr/bin/node /plugins/js/validate.js main.js",
Some(Language::TypeScript) => "/usr/bin/tsc main.ts",
Some(Language::Go) => "/usr/bin/go build -ldflags \"-s -w\" main.go",
Some(Language::Java) => "/usr/bin/java -cp . Main",
None => return Err(Error::LanguageNotFound(request.language)),
};
debug!("build command: {}", cmd);

View File

@ -109,7 +109,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init_from_env(env);
let addr = "127.0.0.1:4003".parse()?;
let addr = "0.0.0.0:4003".parse()?;
let river = RiverService::default();
info!("listen on: {}", addr);