如果你public class的后面是abc,则文件名也得是abc.java public class abc{ ... }然后健一个setenv.bat内容和下面的类是,相应的改成你的。把这个放到你的工作目录,先运行这个bat文件,再编译你的abc.java。 @echo on @rem This script should be used to set up your environment for @rem compiling and running the examples included with WebLogic @rem Server. It contains the following variables: @rem @rem WL_HOME - This must point to the root directory of your WebLogic @rem installation. @rem JAVA_HOME - Determines the version of Java used to compile @rem and run examples. This variable must point to the @rem root directory of a complete JDK installation. See @rem the WebLogic platform support page @rem (http://www.weblogic.com/docs51/platforms/index.html) @rem for an up-to-date list of supported JVMs on Windows NT. @rem @rem When setting these variables below, please use short file names(8.3). @rem To display short (MS-DOS) filenames, use "dir /x". File names with @rem spaces will break this script. @rem @rem jDriver for Oracle users: This script assumes that native libraries @rem required for jDriver for Oracle have been installed in the proper @rem location and that your system PATH variable has been set appropriately. @rem For additional information, refer to Installing and Setting up WebLogic @rem Server (/install/index.html in your local documentation set or on the @rem Internet at http://www.weblogic.com/docs51/install/index.html). @rem Set user-defined variables. set WL_HOME=C:\weblogic set JAVA_HOME=c:\jdk1.3 @rem set JAVA_HOME=c:\progra~1\micros~1.2@if exist %WL_HOME%\classes\boot\weblogic\Server.class goto checkJava @echo. @echo The WebLogic Server wasn't found in directory %WL_HOME%. @echo Please edit the setEnv.cmd script so that the WL_HOME @echo variable points to the WebLogic Server installation directory. @goto finish:checkJava @if exist %JAVA_HOME%\bin\java.exe goto java @if exist %JAVA_HOME%\Bin\JView.exe goto jview @if exist %JAVA_HOME%\..\JView.exe goto jview @echo. @echo The JDK wasn't found in directory %JAVA_HOME%. @echo Please edit the setEnv.cmd script so that the JAVA_HOME @echo variable points to the location of your JDK. @goto finish:java set RMIFORMS= set JDK_CLASSES=%JAVA_HOME%\lib\tools.jar; @if exist %JAVA_HOME%\lib\classes.zip goto jdk11 @goto setEnv:jdk11 set JDK_CLASSES=%JAVA_HOME%\lib\classes.zip; @goto setEnv:jview set JDK_CLASSES=%windir%\Java\classes\classes.zip; set RMIFORMS=;%WL_HOME%\lib\rmiForMs.zip @goto setEnv:setEnv set CLIENT_CLASSES=%WL_HOME%\myserver\clientclasses set SERVER_CLASSES=%WL_HOME%\myserver\serverclasses set SERVLET_CLASSES=%WL_HOME%\myserver\servletclassesset CLASSPATH=.;c:\weblogic\lib\Table111.jar;c:\weblogic\XML\xerces.jar;C:\weblogic\lib\weblogicaux.jar;c:\weblogic\XML\jaxp.jar;c:\weblogic\XML\crimson.jar;c:\weblogic\XML\xalan.jar;c:\weblogic\mssqlserver4\classes;c:\weblogic\mssqlserver4\license;c:\%JDK_CLASSES%%WL_HOME%\license;%WL_HOME%\classes;%WL_HOME%\lib\weblogicaux.jar;%CLIENT_CLASSES%;%SERVER_CLASSES%%RMIFORMS%set PATH=%WL_HOME%\bin;%JAVA_HOME%\bin;%PATH%:finish
可能之二:环境变量设置错误。
另外,你可以用jbuilder。
我觉得初学者最好还是使用非ide的开发环境。
实际上你要是只用java api的话,一个最简单的方法就是set classpath=
清空环境变量就可以了,以后有特殊的要求自己在把class加道classpath中。
很有可能,你的环境变量设置有问题,你应该检查一下。如果还不能解决,那么将环境变量里面的ClassPath、Java_Home删除(如果有的话),并将Path里面有关JDK的设置删除!反正没有也可以。将程序放在jdk\bin下编译、运行,肯定可以!Kevon
and my mail is :[email protected]
set classpath=.;
其中没有main()是吧,
如果是applet就要用appletview.exe或都filename.html
<applet code="Hello.class" width=300 height=300></applet>写得真多
一,你的程序里有
public void static main(String[] args)
这个主方法吗?没有请加上
二,用set classpath命令显示一下classpath路径值,是否包含你程序所在的路径呢?
没有,请使用:set classpath=.;盘符:\你的HelloWorld所在的路径
注意:一定要在path路径中加入你的\JDK所在的目录\bin,这样可以在任何目录下使用javac和java,
javac和java命令后面均不能直接跟目录
所以调试时一定要到当前目录去调试
public class abc{
...
}然后健一个setenv.bat内容和下面的类是,相应的改成你的。把这个放到你的工作目录,先运行这个bat文件,再编译你的abc.java。
@echo on
@rem This script should be used to set up your environment for
@rem compiling and running the examples included with WebLogic
@rem Server. It contains the following variables:
@rem
@rem WL_HOME - This must point to the root directory of your WebLogic
@rem installation.
@rem JAVA_HOME - Determines the version of Java used to compile
@rem and run examples. This variable must point to the
@rem root directory of a complete JDK installation. See
@rem the WebLogic platform support page
@rem (http://www.weblogic.com/docs51/platforms/index.html)
@rem for an up-to-date list of supported JVMs on Windows NT.
@rem
@rem When setting these variables below, please use short file names(8.3).
@rem To display short (MS-DOS) filenames, use "dir /x". File names with
@rem spaces will break this script.
@rem
@rem jDriver for Oracle users: This script assumes that native libraries
@rem required for jDriver for Oracle have been installed in the proper
@rem location and that your system PATH variable has been set appropriately.
@rem For additional information, refer to Installing and Setting up WebLogic
@rem Server (/install/index.html in your local documentation set or on the
@rem Internet at http://www.weblogic.com/docs51/install/index.html). @rem Set user-defined variables.
set WL_HOME=C:\weblogic
set JAVA_HOME=c:\jdk1.3
@rem set JAVA_HOME=c:\progra~1\micros~1.2@if exist %WL_HOME%\classes\boot\weblogic\Server.class goto checkJava
@echo.
@echo The WebLogic Server wasn't found in directory %WL_HOME%.
@echo Please edit the setEnv.cmd script so that the WL_HOME
@echo variable points to the WebLogic Server installation directory.
@goto finish:checkJava
@if exist %JAVA_HOME%\bin\java.exe goto java
@if exist %JAVA_HOME%\Bin\JView.exe goto jview
@if exist %JAVA_HOME%\..\JView.exe goto jview
@echo.
@echo The JDK wasn't found in directory %JAVA_HOME%.
@echo Please edit the setEnv.cmd script so that the JAVA_HOME
@echo variable points to the location of your JDK.
@goto finish:java
set RMIFORMS=
set JDK_CLASSES=%JAVA_HOME%\lib\tools.jar;
@if exist %JAVA_HOME%\lib\classes.zip goto jdk11
@goto setEnv:jdk11
set JDK_CLASSES=%JAVA_HOME%\lib\classes.zip;
@goto setEnv:jview
set JDK_CLASSES=%windir%\Java\classes\classes.zip;
set RMIFORMS=;%WL_HOME%\lib\rmiForMs.zip
@goto setEnv:setEnv
set CLIENT_CLASSES=%WL_HOME%\myserver\clientclasses
set SERVER_CLASSES=%WL_HOME%\myserver\serverclasses
set SERVLET_CLASSES=%WL_HOME%\myserver\servletclassesset CLASSPATH=.;c:\weblogic\lib\Table111.jar;c:\weblogic\XML\xerces.jar;C:\weblogic\lib\weblogicaux.jar;c:\weblogic\XML\jaxp.jar;c:\weblogic\XML\crimson.jar;c:\weblogic\XML\xalan.jar;c:\weblogic\mssqlserver4\classes;c:\weblogic\mssqlserver4\license;c:\%JDK_CLASSES%%WL_HOME%\license;%WL_HOME%\classes;%WL_HOME%\lib\weblogicaux.jar;%CLIENT_CLASSES%;%SERVER_CLASSES%%RMIFORMS%set PATH=%WL_HOME%\bin;%JAVA_HOME%\bin;%PATH%:finish
java -classpath . foo欢迎光临Java,J2EE论坛( http://letsjava.yeah.net )。
http://www.minij2ee.com/