批处理文件运行java,如何通过批处理文件运行JAVA程序

博主在尝试通过bat文件运行包含两个外部jar库的Java程序时遇到ClassNotFoundException。已确保类路径设置正确,但错误依然存在。错误提示显示找不到主类Reminder。解决方案包括检查classpath中的空格和使用`java -cp`命令正确指定类路径。
摘要由CSDN通过智能技术生成

I have already visited the Thread:How to run java application by .bat file

but did not help me.

I have written one java program, which uses the two external jar libraries

I am able to compile my class.So I wrote the bat file in order to execute my java class

but I am getting Class not found exception.

My class name is Reminder.java

My bat file is

@ECHO ON

set CLASSPATH=.

set CLASSPATH=C:\iWaveSoftware\ITSM adapters-2.5_inst1\lib\depends\derby-10.5.3.0_1.jar,C:\iWaveSoftware\ITSM

adapters-2.5_inst1\lib\depends\derbyclient-10.5.3.0_1.jar

JAVA -Xms100M -Xmx500M Reminder`

I am getting the below error if i run my windows bat file

Exception in thread "main" java.lang.NoClassDefFoundError: Reminder

Caused by: java.lang.ClassNotFoundException: Reminder

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

Could not find the main class: Reminder. Program will exit.

Thanks in Advance........Plz help me.

解决方案

1) There are spaces in your classpath. Sometimes that causes error. Put classpath in quotes. ""

2) use java -cp %CLASSPATH% ... Reminder or (if it has package use package.subpackage.Reminder e.g java.util.List)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值