Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts! Good day.

I am having a trouble on my java installation.
When I try to run a .bat file that runs a java program is having an error.

It says "could not find or load main class".


Help me please! Thank you!

What I have tried:

1. I already added the location of jdk bin folder to the path of environment variable but still having an error.

2. I can also run the command on cmd "java -version" and it's working already with that command. That means java was already installed.
Posted
Updated 16-Aug-16 22:01pm

1 solution

The error is because Java could not find the main class of the code you are trying to run. Check that you are using the correct path and name to the class file.
 
Share this answer
 
Comments
Member 12689028 29-Aug-16 22:14pm    
I would like to thank you for your time helping me on this.

Just a question.
Is there any difference running this application on WIN7 vs WIN8?

I run this program on Win7 and there's no error.

I'm trying to run this on Windows 8.1 and i'm getting this error.

Is there any difference? Thanks in advance! :)
Richard MacCutchan 30-Aug-16 3:29am    
No there is no difference. Java programs run inside the Java Virtual Machine, which (in theory at least) is exactly the same in every operating system. If you are getting the same error then it is because the JVM cannot find your program. Check that your path is correct and that you are calling the program from the correct directory; this is especially important if the program is part of a Java package.
Member 12689028 30-Aug-16 23:18pm    
Thanks for the reply.

This is the program that I'm trying to run.
I did the same steps on running it on win7 to win 8.1.
Can you check if it's working fine on your end and can you please tell me what OS are you using?

https://www.mediafire.com/?8c7c64cdy4i1ns0

I'm sorry for being so dumb about this thing sir, I just don't know much about java but I need to make it work because it's my job. I really need your help. Thanks.
Richard MacCutchan 31-Aug-16 3:46am    
Well if it's your job you really need to make more of an effort to understand how it works. What is the structure of your program (i.e. stand alone or part of a package)? Where are the classes located, and where are you trying to run the code from? See Lesson: Common Problems (and Their Solutions) (The Java™ Tutorials > Getting Started)[^].
Member 12689028 31-Aug-16 6:04am    
Yeah, I think I really need to dig deeper on that. Actually i'm only working for hardware selling company but since I need to help client's software to run on our hardware I need to assist them on this matter. But, anyway, I really appreciate your time on giving me solution on this. I'll just read first all the links that you gave me. Thank you so much sir. Godbless. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900