我正在尝试配置我的系统以允许Java DB / derby。
我按照this website上的教程,通过控制面板的高级系统设置更改了JAVA_HOME
环境变量。
我打开命令提示符,使用以下命令行运行setEmbeddedCP.bat
:
c:\Program Files\Java\jdk1.8.0_60\db\bin>setEmbeddedCP.bat
这就是输出:
未设置DERBY_HOME或DERBY_INSTALL。设置其中一个变量
到Derby安装的位置。
我正在网上搜索答案。我不确定是否应该直接打开bat文件并更改该文件中的变量或再次通过高级系统设置。任何见解将不胜感激。
@rem set DERBY_INSTALL=%JAVA_HOME%\db
@if "%DERBY_HOME%"=="" set DERBY_HOME=%DERBY_INSTALL%
@if "%DERBY_HOME%"=="" goto noderbyhome
@FOR %%X in ("%DERBY_HOME%") DO SET DERBY_HOME=%%~sX
set CLASSPATH=%DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib\derbytools.jar;%DERBY_HOME%/lib/derbyoptionaltools.jar;%CLASSPATH%
@goto end
:noderbyhome
@echo DERBY_HOME or DERBY_INSTALL not set. Set one of these variables
@echo to the location of your Derby installation.
@goto end
:end
答案 0 :(得分:0)
setEmbeddedCP.bat
的第三个命令行检查是否定义了环境变量DERBY_HOME
,在您的环境中不是这种情况导致获取错误消息输出。
如果未定义DERBY_INSTALL
,则第二个命令行会将环境变量DERBY_HOME
的值分配给变量DERBY_HOME
。
第一行将定义变量DERBY_INSTALL
,其中包含 Java 目录中子目录db
的路径,但此行已注释掉,因为命令 rem 。
因此,在 Java 目录的子目录db
中安装了 Derby ,您只需要删除命令 rem 和此命令后的空格。
顺便说一句:这个批处理文件编码很难看。更好的是:
@echo off
rem Define installation directory of Derby which is by default the
rem subdirectory "db" in directory of Java. Modify this line if the
rem files derby.jar, derbytools.jar and derbyoptionaltools.jar are
rem not installed into subdirectory "db\lib" of the Java directory.
rem Altenatively the environment variable DERBY_HOME can be defined
rem with path to main directory of Derby installation to use.
set "DERBY_INSTALL=%JAVA_HOME%\db"
if "%DERBY_HOME%"=="" set "DERBY_HOME=%DERBY_INSTALL%"
if "%DERBY_HOME%"=="" (
echo Error detected by %~f0:
echo.
echo DERBY_HOME or DERBY_INSTALL not set. Set one of these
echo variables to the location of your Derby installation.
echo.
pause
goto :EOF
)
rem Get directory path of DERBY in short 8.3 format.
for %%X in ("%DERBY_HOME%") do set "DERBY_HOME=%%~sX"
rem Define the class path with additional Derby Java archives.
set "CLASSPATH=%DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib\derbytools.jar;%DERBY_HOME%\lib\derbyoptionaltools.jar;%CLASSPATH%"
批处理文件setEmbeddedCP.bat
看起来像是 Java 目录中Derby安装目录bin
的子目录db
。
考虑到这一事实,批处理文件setEmbeddedCP.bat
可以分别确定安装Derby的主目录,在批处理文件的顶部有两条简单的行,而不是命令行 set
@echo off
rem Define installation directory of Derby which is by default the
rem subdirectory "db" in directory of Java. This batch file is by
rem default in the subdirectory "bin" of the Derby directory "db".
rem Determine the Derby installation directory from directory of
rem this batch file.
set "DERBY_INSTALL=%~dp0"
set "DERBY_INSTALL=%DERBY_INSTALL:\bin\=%"
rem Altenatively the environment variable DERBY_HOME can be defined
rem with path to main directory of Derby installation to use.
if "%DERBY_HOME%"=="" set "DERBY_HOME=%DERBY_INSTALL%"
if "%DERBY_HOME%"=="" (
echo Error detected by %~f0:
echo.
echo DERBY_HOME or DERBY_INSTALL not set. Set one of these
echo variables to the location of your Derby installation.
echo.
pause
goto :EOF
)
rem Get directory path of DERBY in short 8.3 format.
for %%X in ("%DERBY_HOME%") do set "DERBY_HOME=%%~sX"
rem Define the class path with additional Derby Java archives.
set "CLASSPATH=%DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib\derbytools.jar;%DERBY_HOME%\lib\derbyoptionaltools.jar;%CLASSPATH%"
要了解使用的命令及其工作原理,请打开命令提示符窗口,执行以下命令,并完全阅读为每个命令显示的所有帮助页面。
echo /?
for /?
got /?
if /?
pause /?
rem /?
set /?