当前位置: 首页 > 工具软件 > java2html > 使用案例 >

如何将Java源代码转换为HTML页面

乔丁雨
2023-12-01

Java2HTML是将Java源代码转换为彩色和可浏览HTML页面的工具,其步骤非常简单。

转换步骤

1)下载Java2HTML – http://www.java2html.com/download.html

2)解压缩,例如“ D:\ Java2HTML”

3)编辑“ j2h.bat”文件并修改CLASSPATH变量。 确保它指向正确的j2h.jar库。

@echo off
REM Change this Script, to suit your needs

REM The next few line combines the command line args into one
set _j2h_parameter=
:GetParameter
if "%1" == "" goto end
set _j2h_parameter=%_j2h_parameter% "%1"
shift
goto GetParameter
:end

REM runs Java2HTML
set MBACKUP=%CLASSPATH%
set CLASSPATH=D:\Java2HTML\j2h.jar;%CLASSPATH%
java j2h %_j2h_parameter%
set CLASSPATH=%MBACKUP%

4)将“ j2h”设置为Windows环境变量。 (如果需要全局访问该命令)

5)发出以下命令

C:\>j2h -js D:\Java2HTML\source -d D:\Java2HTML\output

D:\ Java2HTML \ source是要转换的Java源代码
D:\ Java2HTML \ output是生成的HTML输出文件夹

结果

–这是将所有TestNG源代码转换为HTML页面的示例。

C:\>j2h -js D:\Java2HTML\source -d D:\Java2HTML\output
Java2HTML Version 1.5
Copyright (c) 1999-2007, Enterprise Solution Consultants Limited, All Rights Reserved.
New Versions available from http://www.java2html.com
(type j2h with no arguments to get help)
Created D:\Java2HTML\output\stylesheet.css
Created D:\Java2HTML\output\front.html
Created: D:\Java2HTML\output\org\testng\internal\Invoker.java.html
Created: D:\Java2HTML\output\org\testng\ClassMethodMap.java.html
Created: D:\Java2HTML\output\org\testng\v6\TestPlan.java.html
Created: D:\Java2HTML\output\org\testng\annotations\Test.java.html
Created: D:\Java2HTML\output\org\testng\internal\annotations\JDK14TagFactory.java.html
Created: D:\Java2HTML\output\org\testng\annotations\AfterMethod.java.html
Created: D:\Java2HTML\output\org\testng\internal\TestMethodWorker.java.html
Created: D:\Java2HTML\output\org\testng\JUnitConverter.java.html
Created: D:\Java2HTML\output\org\testng\internal\BaseClassFinder.java.html
Created: D:\Java2HTML\output\org\testng\internal\AnnotationTestConverter.java.html
Created: D:\Java2HTML\output\org\testng\junit\JUnitDirectoryConverter.java.html
Created: D:\Java2HTML\output\org\testng\JUnitConverterTask.java.html
Created: D:\Java2HTML\output\org\testng\remote\strprotocol\GenericMessage.java.html
Created: D:\Java2HTML\output\org\testng\xml\ClassSuite.java.html
Created: D:\Java2HTML\output\org\testng\internal\thread\ThreadTimeoutException.java.html
Created: D:\Java2HTML\output\org\testng\internal\BaseTestMethod.java.html
Created: D:\Java2HTML\output\org\testng\annotations\TestInstance.java.html

翻译自: https://mkyong.com/java/how-to-convert-java-source-code-to-html-page/

 类似资料: