急。。怎么自动设置临时JAVA环境变量!在线等。

minlucky 2009-06-22 03:24:21
@ECHO OFF
SET TOMCAT_HOME=C:\LingKeSoft\tomcat-6.0.18
SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
SET PATH= %JAVA_HOME%\bin
SET CLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;
@ECHO ON
REM 启动系统
@ECHO OFF
%TOMCAT_HOME%\bin\tomcat6.exe


机器中没有设置JAVA环境变量,我想在TOMCAT启配置动时设置临时环境变量(不手动环境变量),上面代码是我写的批处理文件,但是不起作用。
请各位大哥,大姐帮忙给看下!在线等。。。
...全文
404 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
bingsha1976 2009-06-23
  • 打赏
  • 举报
回复
C:\Program Files\Java\jdk1.6.0_03


java换个目录安装 Program Files目录有空格

比如C:\Java\jdk1.6.0_03
我那天试试能启动没问题
xnjnmn 2009-06-22
  • 打赏
  • 举报
回复
LZ我只说下
要把这些设置成系统变量
minlucky 2009-06-22
  • 打赏
  • 举报
回复
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 562770 2007-08-04 22:13:58Z markt $
rem ---------------------------------------------------------------------------

SET JAVA_HOME="C:\Program Files\Java\jdk1.6.0_03"
SET PATH= %JAVA_HOME%\bin
SET CLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%CURRENT_DIR%
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set CATALINA_HOME=%cd%
cd %CURRENT_DIR%
:gotHome
.
.
是这样加吗?还是不能启动啊。
bingsha1976 2009-06-22
  • 打赏
  • 举报
回复
还有一点Java不要安装在Program Files下,
有空格,有可能会有问题。
bingsha1976 2009-06-22
  • 打赏
  • 举报
回复
SET JAVA_HOME=D:\java\jdk1.6.0
SET PATH=%JAVA_HOME%\bin
SET CLASSPATH=%JAVA_HOME%\lib\*.jar;

apache-tomcat-6.0.18\bin\startup.bat

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 562770 2007-08-04 22:13:58Z markt $
rem ---------------------------------------------------------------------------
加入位置

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%CURRENT_DIR%
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set CATALINA_HOME=%cd%
cd %CURRENT_DIR%
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome

set EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat

rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find %EXECUTABLE%
echo This file is needed to run this program
goto end
:okExec

rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

:end


另存一个文件

直接运行新的文件就可以
minlucky 2009-06-22
  • 打赏
  • 举报
回复
@ECHO OFF
SET TOMCAT_HOME=C:\LingKeSoft\tomcat-6.0.18
SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
SET PATH= %JAVA_HOME%\bin
SET CLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;
@ECHO ON
REM 启动系统
@ECHO OFF
%TOMCAT_HOME%\bin\tomcat6.exe

红色字体 :不是内部或外部命令,也不是可运行的程序或批处理文件。
我删除点红色字体,写出这样。


@ECHO OFF
SET JAVA_HOME="C:\Program Files\Java\jdk1.6.0_03"
SET PATH= %JAVA_HOME%\bin
SET CLASSPATH=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar;
@ECHO ON
REM 启动系统
@ECHO OFF
C:\LingKeSoft\tomcat-6.0.18\bin\tomcat6.exe
没有错误,但是TOMCAT还是启动不了。
Johnson_Hong 2009-06-22
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 minlucky 的回复:]
TOMCAT一启动就窗口就关了。错误信息看不到。
[/Quote]
调出cmd窗口,cd命令到tomcat的目录下去执行,就不会关闭了
xnjnmn 2009-06-22
  • 打赏
  • 举报
回复
这个脚本用于自动设置环境变量

http://webservices.ctocio.com.cn/wsjavtec/134/7699634.shtml
minlucky 2009-06-22
  • 打赏
  • 举报
回复
TOMCAT一启动就窗口就关了。错误信息看不到。
qiheia 2009-06-22
  • 打赏
  • 举报
回复
有什么错误提示之类的吗??
minlucky 2009-06-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 qiheia 的回复:]
SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
这里好像有点问题

Program Files中间有空格,有空格的话是不能设置的
应该要加引号
SET JAVA_HOME="C:\Program Files\Java\jdk1.6.0_03"
[/Quote]

谢谢你。但是我加上引号也不能启动TOMCAT.还有其他的问题吗?
qiheia 2009-06-22
  • 打赏
  • 举报
回复
SET JAVA_HOME=C:\Program Files\Java\jdk1.6.0_03
这里好像有点问题

Program Files中间有空格,有空格的话是不能设置的
应该要加引号
SET JAVA_HOME="C:\Program Files\Java\jdk1.6.0_03"

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧