I have coded in c++ in visual studio for several years.
I am now working in java with eclipse.
the java programs are launched from a .bat file so I cannot breakpoint them to debug.
Without being able to step through my code i am finding it very hard to find the root cause of the error as the thrown exception is not usually the source of the problem.
How can I debug my code without access to breakpoints ?
You can find the main method, as suggested by Ben J, and run this from Eclipse. To pass arguments to it, edit the run configuration. e.g. Right-click on the main class, click "Run As" and then "Run Configurations...". Select the "Arguments" tab and enter whatever you need.
Or since you need to debug this, click "Debug As" and "Debug Configurations..." instead.
Use Maven or Ant to launch your programs, instead of a batch file. There is much better integration with Eclipse.
Related
So I just installed JRE, JDK and Eclipse and I was trying to run this famous HelloWorld code, but it shows this message as in attached images. What's the ant build?
Thanks!
dont run it as ant, right click on your file in eclipse select run as then choose java application
It looks like you don't have your file in your buildpath (what eclipse uses to figure out what files it should compile). Right click on the folder and select Buildpath -> Use as Source folder. Now when you hit run it should hopefully work.
Go to Run
Run Configurations
Select Java Application(From Left Pane)
Fill Up Your Project Name and your Main Class
Apply and Run
example image
Best way is to
Delete all eclipse files in your pc and again download eclipse and install it. Definitely works
Click Run As > Java.
If Java is not available there, click Run Configurations > JRE.
Choose "Execution environment" , click Environments and choose the Java version you want to use. Click Apply, Run.
That should do it.
Try to create a Java class file with suitable name and method.This error usually occurs when compiler doesn't understand which file to execute.
Simply click the javadoc next to your console and run it
I am a beginner with Java, Maven, and Eclipse.
I have made a simple standalone Java program and generated a Maven package with Eclipse LUNA. When I began to debug the Java program, I found that breakpoints did not work. When setting the breakpoint, there will be a circle at the beginning of code line.
Now there was circle, but it had a line over the circle.
How can I execute debugging the Java program with Maven in Eclipse?
Do it like this:
a.Right click project.Then, Debug as -> Maven build ...
b.In the goals field put -Dmaven.surefire.debug test
c.In the parameters put a new parameter called forkMode with a value of never
Set your breakpoints down and run this configuration and it should hit the breakpoint.
If you are really saying "line over circle" then you have breakpoints there in eclipse and disabled.
Go to "Debug" view > Breakpoints and enable you should stop at your breakpoints then in your debug session
I seem to be able to run Java programs and get output in Eclipse when I use StdOut.println(...). I have a program that reads from StdIn and should print to StdOut. I know the program works because I have submitted it to a class autograder and got a perfect score on it, but I must be doing it wrong in Eclipse. Please explain how to set this up. I thought I understood how to use the "Run Configuration", but obviously I don't.
Follow these steps.
Right click on the project that you want to run. (In Eclipse)
From the appeared menu, Select Run As
Then finally select Java Application
And make sure, Your console is visible in your Eclipse IDE,
To Enable it,
Goto Windows tab in Eclipse IDE
Then Select Show View
Finally select Console
I am used to Eclipse, in that when I save a file, it automatically generates the class file, so that when I run my application the change is already there.
Netbeans seems to be different unfortunately. Everytime I do a little change (and want to see that change), I have to go up to Run-->Clean And Build Project, then find my Java file and select 'Run File'.
Is there any way in Netbeans to speed up this process?
First: you don't need "Clean and build project" each time.
Just use "Run project" (or "Run Main Project") and NetBeans will take care of compiling whatever needs compiling.
But if you do want the "Compile on Save" feature you can enable that in the project's properties under the "Build -> Compiling" options:
For more details on Compile-On-Save see the official FAQ page http://wiki.netbeans.org/FaqCompileOnSave
I would just like to mention in case it helps anyone, that for my "Maven Web Application" project, every time I checked "Compile On Save" and clicked OK, it would not save it. I would reopen the Project Properties to find it unselected. As it turns out the reason was that the nb-configuration.xml for the project was made read-only from source control.
When compiling android stuff in eclipse, I am forever annoyed when I hit the "Run" button to compile and run, if I am in a .java file everything works great if im in an .xml file (for android layouts) it compiles the xml file and produces an _out.xml file which screws up the project so that I first have to delete the "out" file then clean my project files.
Any quick answer on how to disable the compiling of xml files?
Samuel has told already a solution. What I prefer is to use the "always run the last project" setting.
Go to window -> preferences -> Run/Debug -> Launching and than activate the option on the bottom labeled: "Always launch the previously launched application"
If you have multiple projects you will sometimes have the issue that you start a project you didn't meant to start. That will occur only once, because after starting the right project, you will stick to that until you switch to the next project (which shouldn't happen very often on a working day).
Its not a perfect solution, but prevents the mentioned issue with, in my experience, the lowest/smallest (whats the right term?) side effects.
There is no way to do this, the reason it happens is because of the fact that when you click "run" it's trying to run the .xml instead of the Project its-self. The easiest thing to do to avoid this, is when you go to hit run do a Ctrl+s, then click on the project folder, then hit run, or do the same thing, but switch tab to a .java file. Sorry to be the bearer or bad news, when I started I had the same problem.. drove me crazy, but when you get into the new habit, you're just fine!