From 32b3c4ac88a9854939c2c92bb2ca8af024ca330f Mon Sep 17 00:00:00 2001 From: Jered Ye <87924680+JeredYe@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:46:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JuderUI/{src/edu/dhu/ws => }/OJWS.java | 0 JuderUI/src/META-INF/jax-ws-catalog.xml | 1 + .../106.15.36.190_80/oj/webservice/OJWS.wsdl | 2 +- JuderUI/src/gui/Control.java | 9 + JuderUI/src/gui/MainFrame.form | 76 +- JuderUI/src/gui/MainFrame.java | 77 +- JuderUI/src/web/DisableHostnameVerifier.java | 34 + JuderUI/src/web/Webservice.java | 96 +- .../106.15.36.190_80/oj/webservice/OJWS.wsdl | 2 +- .../oj/webservice/OJWS.wsdl | 878 ++++++++++++++++++ Judger/src/kernel/Judger.java | 7 +- 11 files changed, 1113 insertions(+), 69 deletions(-) rename JuderUI/{src/edu/dhu/ws => }/OJWS.java (100%) create mode 100644 JuderUI/src/web/DisableHostnameVerifier.java create mode 100644 JuderUI/xml-resources/web-service-references/OJWS/wsdl/219.228.76.122_443/oj/webservice/OJWS.wsdl diff --git a/JuderUI/src/edu/dhu/ws/OJWS.java b/JuderUI/OJWS.java similarity index 100% rename from JuderUI/src/edu/dhu/ws/OJWS.java rename to JuderUI/OJWS.java diff --git a/JuderUI/src/META-INF/jax-ws-catalog.xml b/JuderUI/src/META-INF/jax-ws-catalog.xml index c090d75..861ed9d 100644 --- a/JuderUI/src/META-INF/jax-ws-catalog.xml +++ b/JuderUI/src/META-INF/jax-ws-catalog.xml @@ -3,4 +3,5 @@ + \ No newline at end of file diff --git a/JuderUI/src/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl b/JuderUI/src/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl index e3a5ea8..f277d8e 100644 --- a/JuderUI/src/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl +++ b/JuderUI/src/META-INF/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl @@ -872,7 +872,7 @@ - + \ No newline at end of file diff --git a/JuderUI/src/gui/Control.java b/JuderUI/src/gui/Control.java index 9a45cf4..18549ef 100644 --- a/JuderUI/src/gui/Control.java +++ b/JuderUI/src/gui/Control.java @@ -21,6 +21,7 @@ import java.util.List; import java.util.Queue; import javax.swing.JEditorPane; import javax.swing.JOptionPane; +import javax.swing.JTextField; import javax.swing.text.Element; import javax.xml.namespace.QName; import myjdom.model.Solution; @@ -124,6 +125,14 @@ public class Control { } // + public static JTextField getDistributorField(int a) { + switch (a) { + case 0: + return mainFrame.distributorIP; + default: + return mainFrame.distributorPort; + } + } public static JEditorPane getJudgeInfoEditorPane(int a) { switch (a) { case 1: diff --git a/JuderUI/src/gui/MainFrame.form b/JuderUI/src/gui/MainFrame.form index 9603eea..3519b40 100644 --- a/JuderUI/src/gui/MainFrame.form +++ b/JuderUI/src/gui/MainFrame.form @@ -63,6 +63,9 @@ + + + @@ -80,26 +83,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -123,12 +106,37 @@ + + + + + + + + + + + + + + + + + + + + + + - + + + + - - + + @@ -149,6 +157,7 @@ + @@ -204,6 +213,7 @@ + @@ -217,6 +227,9 @@ + + + @@ -550,6 +563,23 @@ + + + + + + + + + + + + + + + + + diff --git a/JuderUI/src/gui/MainFrame.java b/JuderUI/src/gui/MainFrame.java index f605400..f3c947f 100644 --- a/JuderUI/src/gui/MainFrame.java +++ b/JuderUI/src/gui/MainFrame.java @@ -22,6 +22,7 @@ import javax.swing.JOptionPane; import javax.xml.namespace.QName; import share.gui.NewCompileSetting; import web.Dubboservice; +import web.Webservice; /** * @@ -130,6 +131,7 @@ public class MainFrame extends javax.swing.JFrame { comboCppCompiler = new javax.swing.JComboBox(); jLabel10 = new javax.swing.JLabel(); comboJavaCompiler = new javax.swing.JComboBox(); + jCheckBox2 = new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); @@ -289,6 +291,16 @@ public class MainFrame extends javax.swing.JFrame { comboJavaCompiler.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + jCheckBox2.setFont(new java.awt.Font("宋体", 2, 12)); // NOI18N + jCheckBox2.setForeground(new java.awt.Color(0, 204, 102)); + jCheckBox2.setText("dubbo"); + jCheckBox1.setToolTipText("下次程序启动时,自动开始裁判"); + jCheckBox2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckBox2ActionPerformed(evt); + } + }); + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( @@ -299,25 +311,6 @@ public class MainFrame extends javax.swing.JFrame { .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel2Layout.createSequentialGroup() - .addComponent(jButton2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel8) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(9, 9, 9) - .addComponent(jLabel10) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(jLabel4) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(20, 20, 20)) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(button_Start) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) @@ -339,10 +332,33 @@ public class MainFrame extends javax.swing.JFrame { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(button_StartThread)))) - .addComponent(threadManagerTabb, javax.swing.GroupLayout.PREFERRED_SIZE, 955, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(49, 49, 49) - .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)) + .addComponent(button_StartThread)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jButton2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel8) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(comboCppCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(9, 9, 9) + .addComponent(jLabel10) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(comboJavaCompiler, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jCheckBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(36, 36, 36)))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(threadManagerTabb, javax.swing.GroupLayout.PREFERRED_SIZE, 955, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(28, 28, 28))) + .addGap(21, 21, 21) + .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 1, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -359,7 +375,8 @@ public class MainFrame extends javax.swing.JFrame { .addComponent(jLabel4) .addComponent(distributorPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(distributorIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel3))) + .addComponent(jLabel3) + .addComponent(jCheckBox2))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) @@ -449,6 +466,7 @@ public class MainFrame extends javax.swing.JFrame { this.button_Start.setEnabled(false); this.buttonStop.setEnabled(true); this.button_StartThread.setEnabled(true); + Webservice.existDubbo=false; // if(!Dubboservice.running){ // Dubboservice.main(null); // Dubboservice.running=true; @@ -517,6 +535,10 @@ public class MainFrame extends javax.swing.JFrame { } }//GEN-LAST:event_jButton2ActionPerformed + private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed + Webservice.ENABLE_DUBBO=jCheckBox2.isSelected(); + }//GEN-LAST:event_jCheckBox2ActionPerformed + private void loadConfig() { this.distributorIP.setText(Config.getValue("distributorIP")); this.distributorPort.setText(Config.getValue("distributorPort")); @@ -597,11 +619,12 @@ public class MainFrame extends javax.swing.JFrame { javax.swing.JButton button_StartThread; private javax.swing.JComboBox comboCppCompiler; private javax.swing.JComboBox comboJavaCompiler; - private javax.swing.JTextField distributorIP; - private javax.swing.JTextField distributorPort; + public javax.swing.JTextField distributorIP; + public javax.swing.JTextField distributorPort; private javax.swing.JButton jButton1; javax.swing.JButton jButton2; private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JCheckBox jCheckBox2; javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel10; javax.swing.JLabel jLabel14; @@ -617,7 +640,7 @@ public class MainFrame extends javax.swing.JFrame { private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; + public javax.swing.JPanel jPanel2; javax.swing.JPanel jPanel6; javax.swing.JPanel jPanel7; private javax.swing.JScrollPane jScrollPane11; diff --git a/JuderUI/src/web/DisableHostnameVerifier.java b/JuderUI/src/web/DisableHostnameVerifier.java new file mode 100644 index 0000000..d487b65 --- /dev/null +++ b/JuderUI/src/web/DisableHostnameVerifier.java @@ -0,0 +1,34 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package web; +import javax.net.ssl.*; +import java.security.cert.X509Certificate; +/** + * + * @author tange + */ +public class DisableHostnameVerifier { + public static void disable() throws Exception { + // 创建 SSLContext + SSLContext sslContext = SSLContext.getInstance("TLS"); + + // 创建一个 TrustManager,实现 X509TrustManager 接口并禁用主题备用名称检查 + X509TrustManager trustManager = new X509TrustManager() { + public void checkClientTrusted(X509Certificate[] chain, String authType) {} + public void checkServerTrusted(X509Certificate[] chain, String authType) {} + public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } + }; + + // 初始化 SSLContext,将自定义的 TrustManager 添加到 TrustManager 数组中 + sslContext.init(null, new TrustManager[] { trustManager }, null); + + // 获取 SSLContext 中的 SSLSocketFactory,并设置为默认的 SSLSocketFactory + HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); + + // 禁用主题备用名称检查 + HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true); + } +} \ No newline at end of file diff --git a/JuderUI/src/web/Webservice.java b/JuderUI/src/web/Webservice.java index b825334..36a7fae 100644 --- a/JuderUI/src/web/Webservice.java +++ b/JuderUI/src/web/Webservice.java @@ -11,8 +11,18 @@ import com.alibaba.dubbo.config.RegistryConfig; import util.Decrypt; import edu.dhu.ws.OJWS; import edu.dhu.ws.OJWS_Service; +import static gui.Control.getDistributorField; +import static gui.Control.getJudgeInfoEditorPane; +import java.net.MalformedURLException; import java.net.URL; +import java.rmi.RemoteException; +import java.time.LocalTime; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.annotation.Resource; +import javax.swing.JEditorPane; +import javax.swing.JOptionPane; +import javax.swing.JTextField; import javax.xml.namespace.QName; import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboService; @@ -24,6 +34,8 @@ import org.apache.dubbo.config.annotation.DubboService; public class Webservice implements java.rmi.Remote{ private OJWS_Service webs; private OJWS servicePort; + public static boolean ENABLE_DUBBO=false; + public static boolean existDubbo=false; //@DubboReference(url = "http://106.15.36.190:3000/edu.dhu.ws.OJWS") //http://106.15.36.190:3000/edu.dhu.ws.OJWS //dubbo://219.228.76.122:80/edu.dhu.ws.OJWS @@ -47,34 +59,81 @@ public class Webservice implements java.rmi.Remote{ // 初始化 return reference.get(); } - - - public Webservice(){ - webs = new OJWS_Service(); - try{ - servicePort = webs.getOJWSImplPort(); - - } - catch(Exception e){} + private void setDubbo(){ + + String url = "dubbo://localhost:8080/edu.dhu.ws.OJWS"; + JTextField ip=getDistributorField(0); + JTextField port=getDistributorField(1); + if(ip!=null)//测试时获取不到控件 + url=String.format("dubbo://%s:%s/edu.dhu.ws.OJWS",ip.getText(),port.getText()); try { - String url = "dubbo://192.168.0.101:20880/edu.dhu.ws.OJWS";//todo:需要改成用户自己输入 + JEditorPane infoPane=getJudgeInfoEditorPane(0); + if(!existDubbo&&infoPane!=null) + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+"正在请求Dubbo服务...\n"); + //String url = "dubbo://219.228.76.122:20880/edu.dhu.ws.OJWS";//todo:需要改成用户自己输入 dubboPort = initDubboPort(url); } catch(Exception e){ + JEditorPane infoPane=getJudgeInfoEditorPane(1); + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+e.getMessage()+"\n"); e.printStackTrace(); } if(dubboPort!=null){ - + JEditorPane infoPane=getJudgeInfoEditorPane(0); + if(!existDubbo&&infoPane!=null) + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+"\nDubbo服务连接成功!URL:"+url+"\n"); + existDubbo=true; servicePort=dubboPort; + }else{ + existDubbo=false; + JEditorPane infoPane=getJudgeInfoEditorPane(1); + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+"\nDubbo服务连接失败!URL:"+url+"\n"); } //如果能使用dubbo服务就使用,不能的话就用原来的 } - public Webservice(URL url,QName qname)throws java.rmi.RemoteException{ - webs = new OJWS_Service(url,qname); - servicePort = webs.getOJWSImplPort(); + + public Webservice(){ + try { + DisableHostnameVerifier.disable(); + } catch (Exception ex) { + Logger.getLogger(Webservice.class.getName()).log(Level.SEVERE, null, ex); + } + if(!ENABLE_DUBBO){ + try{ + + webs = new OJWS_Service(); + servicePort = webs.getOJWSImplPort(); + } + catch(Exception e){ + e.printStackTrace(); + } + } + else + setDubbo(); + } + public Webservice(URL url,QName qname)throws java.rmi.RemoteException, MalformedURLException{ + url=new URL("https",url.getHost(),url.getPort(),url.getFile()); + try { + DisableHostnameVerifier.disable(); + } catch (Exception ex) { + Logger.getLogger(Webservice.class.getName()).log(Level.SEVERE, null, ex); + } + if(!ENABLE_DUBBO){ + try{ + webs = new OJWS_Service(url,qname); + servicePort = webs.getOJWSImplPort(); + + } + catch(Exception e){ + JEditorPane infoPane=getJudgeInfoEditorPane(1); + infoPane.setText(infoPane.getText()+LocalTime.now().toString()+e.getMessage()+"\n"); + } + } + else + setDubbo(); } public String getSolutions(int arg0)throws java.rmi.RemoteException{ String s =this.servicePort.wsGetSolutions("judge","judge123",arg0); @@ -94,6 +153,13 @@ public class Webservice implements java.rmi.Remote{ } public static void main(String[] args) { Webservice ws=new Webservice(); - System.out.println(ws.dubboPort.test("a")); + + try { + System.out.println(ws.getProblem(75)); + } catch (RemoteException ex) { + Logger.getLogger(Webservice.class.getName()).log(Level.SEVERE, null, ex); + } } } + +//////P.S.部署到服务器时要注意账号密码修改 \ No newline at end of file diff --git a/JuderUI/xml-resources/web-service-references/OJWS/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl b/JuderUI/xml-resources/web-service-references/OJWS/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl index e3a5ea8..48c0c92 100644 --- a/JuderUI/xml-resources/web-service-references/OJWS/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl +++ b/JuderUI/xml-resources/web-service-references/OJWS/wsdl/106.15.36.190_80/oj/webservice/OJWS.wsdl @@ -872,7 +872,7 @@ - + \ No newline at end of file diff --git a/JuderUI/xml-resources/web-service-references/OJWS/wsdl/219.228.76.122_443/oj/webservice/OJWS.wsdl b/JuderUI/xml-resources/web-service-references/OJWS/wsdl/219.228.76.122_443/oj/webservice/OJWS.wsdl new file mode 100644 index 0000000..f277d8e --- /dev/null +++ b/JuderUI/xml-resources/web-service-references/OJWS/wsdl/219.228.76.122_443/oj/webservice/OJWS.wsdl @@ -0,0 +1,878 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Judger/src/kernel/Judger.java b/Judger/src/kernel/Judger.java index 2006dab..3642681 100644 --- a/Judger/src/kernel/Judger.java +++ b/Judger/src/kernel/Judger.java @@ -9,6 +9,7 @@ import MyCache.Shared; import common.Config; import resultData.RunInfo; import common.Const; +import common.LangSelector; //import gui.Control; import java.io.BufferedWriter; import java.io.File; @@ -110,17 +111,19 @@ public class Judger { String linkCommand = Config.getCompilerDir(language) + File.separator + "g++ " +"\""+ Config.getTargetPath() +File.separator+"output"+File.separator+ "Main"+".o"+"\"" + " -o " +"\""+ Config.getTargetPath()+File.separator+"output"+File.separator + "Main"+".exe"+"\"\n"; return linkCommand; } + /////////////////////////////////////////////////////////////////////////////////////////////////TODO //mingw32-g++.exe -Wall -g -c E:\Downloads\aaa\aa.cpp -o obj\Debug\aa.o //mingw32-g++.exe -o bin\Debug\aaa.exe obj\Debug\aa.o private String compileCommand(String language) { String compileCommand = ""; - language = language.toLowerCase(); + language = language.toLowerCase();//todo if (language.equals("c")) { compileCommand += "\"" + Config.getCompilerDir(language) + File.separator + "gcc\" -c " + "\""+sourceFile +"\""+ " -o " +"\""+Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main"+".o"+"\"\n"; } else if (language.equals("java")) { compileCommand += "\"" + Config.getCompilerDir(language) + File.separator + "javac\" " + sourceFile; //todo文件路径 } else if (language.equals("cpp")||language.equals("c++")) { - compileCommand += "\"" + Config.getCompilerDir(language) + File.separator + "g++\" -Wall -g -std=c++14 -c " + //compileCommand +=Config.getCompilerDir(language) + File.separator +LangSelector.getCompileCommand("C++",null); + compileCommand += "\"" + Config.getCompilerDir(language) + File.separator + "g++\" -Wall -g -c -std=c++14 "//todo:C++14 + "\""+sourceFile+"\"" + " -o " + "\""+Config.getTargetPath()+ File.separator+"output"+ File.separator + "Main"+".o"+"\"\n"; } else { CompileInfo.info = "this programing language is not support!!!";