Error while running a program on java on visual studio code - java

This is the porgram which I am running on visual studio code
When I run the program I am getting this error box
After getting the error box, it is showing this page.
What shall be done in this for the program to run on VS Code?

There should be multiple java files inside the folder you are currently opening in vscode and you are running one of them. There is a bug in another java script that causes a compilation error when you run the current file.
It doesn't matter, you just need to click on Proceed in the popup, which will continue to run the current code. As long as your current code has no errors, the program will run successfully and output the result.
Another way is to install Code Runner and then use the Run Code option it brings to run the code. This way it will only compile and run the current file, and will not bring compile errors.
But be aware that Code Runner may have errors when your file structure is complex.

Related

Could not find or load main class main using Android Studio

I'm working on learning how to code games in Java. Since Android studio isn't supporting eclipse it just made sense to use the IDE I'm already using to write my Java programs. I had to do some digging but I figured out how to make that work.
My issue is that I can run the programs while in the IDE but when I try to run the program from the command line, even something as simple as "Hello, World" I get this error.
Could not find or load main class main
Now this odd because the director contains both a main.class and a main.java plus the program does compile and run when run from android studio itself. I would like to be able to resolve this to run my programs at the command line.

Error: Could not create the Java Virtual Machine. Only when running MUnit test

I am attempting the run an MUnit test and everytime I try to run it I receive this error in the console:
Unrecognized option: -esb
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I have tried to access the ini file and both decrease and increase the heap size, I have rebooted my pc, and i have stripped the project of it's metadata and then re-imported the project.
I'm not really sure where to go from here. Any help would be greatly appreciated. I made this its own question instead of merging it with another question on here because this only happens when I try to run an MUnit test. It does not happen when trying to load Anypoint Studio or when I run any of my flows within the project. Just when I try to run this one MUnit suite.
That's a bug on the MUnit Studio Plugin. It'll be fixed in the next release(due in a couple of weeks)
I reckon you're running your test from studio, correct?
For the time being, as a workaround, please remove any "-" from your project name. In fact from anywhere in project path.
HTH

Display java application errors in terminal/console

As you know when we building applications we get Errors/Exceptions such as NullPointerException etc. on IDE Console (I'm using IntelliJ IDEA).
I want to display those errors simultaneously in my Mac Terminal for larger view so I don't have to horizontally scroll IDE Console every time when I get big errors.
I don't want to run my applications from Terminal with commands (java class...)
I want to run from my IDE and all texts which is going down(errors,exceptions infos.) will reflect to Terminal.
So is there a any log file that i can look into? How can I achieve this?
In the Logs tab of an IntelliJ IDEA run configuration, there is an option "Save console output to a file". You can use that to save the output of your application to a file and to view it in the terminal.

Java not compiling changes in my code

I have this problem with both Netbeans 8.0 and Eclipse. In Eclipse when I can write a Java program and it will compile and run fine. Then I can make a change to the source and when I run it again sometimes the old version of the code without the change in the one that is run. If I hit run a second time the new version is run.
In NetBeans I get a different error the second time I try to run updated code. "Could not find or load main class". This happens sometimes when I make changes to the source. I think this might have a similar cause to what is going on in Eclipse. In both cases the problems are intermittent and difficult to reliably reproduce.
I am using JDK 7 but before I was using JDK 8 and had the same problem.
I don't know about netbeans but in eclipse if you change code and you don't save before launching sometimes it executes the old code. So ctrl+s or hit the button save before launching every time. It seems that the run and save command are not issued by eclipse in the same order so it runs and saves at the same time but runs the old code.
i don't have the rights to comment right now so here it goes, i faced the similar problem when i was using net-beans 8.0. the main reason behind this problem is your classpath.("could not find or load main class").one way to ignore this problem is to set the classpath as the current directory(which can be done by using " set classpath=*;".). kindly revert if this doesn't solve your problem.
p.s: try it to compile with dos.
"C:\Program Files\Java\jdk1.8.0_05\bin" and you are good to compile.
and in eclipse, when the present src code has some errors.. it tend to compile and run the previous code.

Just installed Eclipse, won't run programs or show errors

new here, but I've got a simple question.
i have just installed the Eclipse Indigo IDE program on my laptop from my college website, as well as the Java Runtime Environment. While Eclipse itself is working and showing code, it won't run, every time I click on the run button, its says "The Selection can't be launched, and there are no recent launches". It also won't show any errors in the code either. This isn't a one time thing either, as I also downloaded it onto my home computer and it has the same problems. I get the impression I need to further configure it but I don't know what to do, can anyone help?

Categories