# icp-web **Repository Path**: sharelords/icp-web ## Basic Information - **Project Name**: icp-web - **Description**: 基于JAVA语言开发的在线编程系统 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 9 - **Forks**: 5 - **Created**: 2020-10-14 - **Last Updated**: 2022-05-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 项目开源地址 https://gitee.com/sharelords/icp-web ## 什么是icp-web? icp-web是In-Circuit Programming Web的缩写,译为在线编程系统。是一款基于JAVA语言开发的在线编程系统,为企业评测和考察JAVA技术人员手写代码的能力,以及JAVA技术人员校验运算逻辑的准确性,提供便利。 - **易部署**:git仓库中检出项目,无需任何配置,即可启动、运行、打包、部署。 - **易操作**:简洁化页面,只保留核心操作组件。 - **易扩展**:使用者可根据自身需要,基于扩展接口对项目进行改造,或嵌入到其他系统中。 - **高效便捷**:编写代码后,一键运行并查看结果,同时支持电脑端和手机端两种模式。 - **使用方便**:提供了便携的页面组件,且支持手机端操作,即用即走。 ## 为什么要使用它? - **节省有类似需求的企业研发成本** - **无需担心设备限制,一台手机即可操作** - **简洁的UI界面,易上手,操作便捷** - **网上随便找出一段代码,即可执行获取运行结果** - **...** ## 使用场景 - **用于测验相关人员手动编写代码的能力;** - **用于手机端或电脑端运行代码,并查看执行结果。** ## 核心功能介绍 - **客户端识别** - **代码编写** - **字号调节** - **增加包名和打印语句** - **重写代码** - **运行程序** - **结果查看** 只列出了部分核心功能,更多功能请自行搭建测试。 ## 环境要求及说明 项目运行环境支持jdk1.7更高版本,spring-boot环境运行,仅支持引入jdk自带方法。 项目在短期内提供网页访问示范,同时支持pc和web访问,访问地址: https://www.sharelords.com/icp-web 使用者宜下载至本地运行使用及自行优化。 除部分核心代码暂不做开源,通过jar包形式引入,其他代码均作开源处理。未开源代码不得用于商业用途,否则,作者有权利追究相关责任。本产品的最终解释权归作者所有。 ## 技术目标 在线编译java源代码,通过动态编译技术,基于内存字节码动态加载class文件,执行main方法并返回执行结果。 ## 项目架构 ![1](./images/1.png) ## 核心代码展示 ![2](./images/2.png) 其中: LogExportProxy是一个代理类,用来代理并处理、保存执行结果; ClassSrcOpera类提供了执行main函数的功能(通过调用mainMethodInvoke函数实现)。 ## 使用案例截图 1)案例1:一般使用 ![3](./images/3.png) 执行使用的源码: import java.util.*; public class Main { public static void main(String[] args) { int[] array = new int[]{2, 4, 3, 1, 5, 8, 7}; for(int element : bubbleSort(array)) { System.out.print(element + " "); } } // 冒泡排序 public static int[] bubbleSort(int[] array) { if (array.length == 0) { return array; } for (int i = 0; i < array.length; i++) { for (int j = 0; j < array.length - 1 - i; j++) { if (array[j + 1] < array[j]) { int temp = array[j + 1]; array[j + 1] = array[j]; array[j] = temp; } } } return array; } } 2)案例2:支持自定义内部类 ![4](./images/4.png) 执行使用的源码: import java.util.*; public class Main { public static void main(String[] args) { long inputLong = 100; List resultList = new InnerClass(inputLong).getPrimeFactor(); for (Integer elem : resultList) { System.out.print(elem + " "); } } // 求质数因子,并按照从小到大排序 static class InnerClass { private long num; public InnerClass(long num) { this.num = num; } public List getPrimeFactor() { if (num <= 1) { return Collections.emptyList(); } List list = new ArrayList<>(); while (num > 1) { for (int i = 2; i <= num; i++) { if (num % i == 0) { list.add(i); num /= i; break; } } } Collections.sort(list); return list; } } }