简体   繁体   English

使用批处理文件设置类路径和路径后,仍然引发错误“找不到或加载主类”

[英]After setting classpath and path using batch file, still throws errors “Can not find or load main class”

Ever since I moved the location of the file, the batch file doesn't seem to want to find the class path. 自从我移动文件的位置以来,批处理文件似乎就不想找到类路径。 I've tried set path="C:\\Program Files\\Java\\jdk1.8.0_131\\bin"; 我试过set path="C:\\Program Files\\Java\\jdk1.8.0_131\\bin"; and set classpath="C:\\Program Files\\Java\\jdk1.8.0_131\\lib" . set classpath="C:\\Program Files\\Java\\jdk1.8.0_131\\lib"

Here's the batch file: 这是批处理文件:

@echo off
color 3
title Run Java File

set path="C:\Program Files\Java\jdk1.8.0_131\bin";
set classpath="C:\Program Files\Java\jdk1.8.0_131\lib";

cd C:\Users\user\Documents\Java Test Files\Matthew C\src\calculator

javac Math.java
java Math

pause

and the calculator.java file is just a simple "Hello World" type program - which works within a built-in compiler that I use - that is Eclipse. 而calculator.java文件只是一个简单的“ Hello World”类型程序,它在我使用的内置编译器中运行,即Eclipse。

Does anyone know why this doesn't work? 有谁知道为什么这不起作用? I've tried searching multiple answers in and out of Stackoverflow, and none of them seemed to have worked for me. 我试图在Stackoverflow内外搜索多个答案,但似乎没有一个对我有用。 Thanks! 谢谢!

Here's a few things to try... 这里有一些尝试的方法...

  1. Try running those commands on command prompt and make sure they work. 尝试在命令提示符下运行这些命令,并确保它们可以正常工作。
  2. Try double-quoting your path to the app (it has spaces in it). 尝试将应用程序的路径双引号(其中包含空格)。
  3. Set JDK path once for the entire system ( like specified here ) 为整个系统设置一次JDK路径( 如此处指定

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法找到或加载设置的主类路径和类路径,但运行时仍出错 - Could not find or load main class path and classpath are set but still error run time 在cmd中使用批处理文件时,无法找到或加载程序的主类 - On using a batch file in cmd Could not find or load main class for a program 添加CLASSPATH后,无法找到或加载主类 - Could not find or load main class, after adding CLASSPATH Java:无法使用类路径使用jar文件加载主类 - Java:Cannot load main class with jar file using classpath 错误:尝试运行JAR时无法找到或加载主类Main。 Manifest和classpath看起来很好,仍然无法正常工作? - Error: Could not find or load main class Main when trying to run JAR. Manifest and classpath look fine, still doesn't work? 不断出错:尽管设置了PATH和CLASSPATH变量,却找不到或加载主类 - Keep getting Error: Could not find or load main class although set the PATH and CLASSPATH variables 在Windows上尝试使用classpath(用于其他lib)从命令行运行jar文件会引发“找不到或加载主类” - Trying to run jar file from command line using classpath(for other libs) raises “Could not find or load main class”, on Windows 设置Java类路径以加载类文件 - Setting Java Classpath to Load a Class File Jar 可执行文件,但找不到主 class 的类路径 - Jar executable but can not find the classpath for main class 执行批处理文件错误:“找不到或加载主类” - Executing batch file error: “Could not find or load main class”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM