How to execute or implement batch file in java project with eclipse - eclipse

Is it possible to implement or extract batch file in eclipse and debug java project in debug mode. Because without batch file I can't debugging my project and can't set breakpoint.Or some another solution. How to debug my application with use .bat file to start my java project.

Is it possible to implement or extract batch file in eclipse and debug java project in debug mode.
Hmm... You can do everything you do with a batch file (assuming you're using it to start a Java program of course) from Eclipse with a Run > Run Configuration... (also available from the contextual menu after a right-click or via the top toolbar).
Because without batch file I can't debugging my project and can't set breakpoint.
Why?! I don't think this is true.
Or some another solution.
Start your class/project in debug mode using Run > Debug (reusing or creating a new Run > Debug Configuration...). Again, this is also available from the contextual menu after a right-click or via the top toolbar.
How to debug my application with use .bat file to start my java project.
To be fully exhaustive, you can run an external program from Eclipse using an Run > External Tools > External Tools Configuration.... And you could indeed use remote debugging options and connect a remote debugger from Eclipse. But honestly, I don't think you need that.
Maybe you should explain what you're trying to do more precisely.

Try remote debugging. Eclipse can attach to remote Java processes, but the Java program must be started with special keys. I don't remember them, google/help for your service.

Related

How to enter debug mode in eclipse when launching tomcat from cmd

I am using apache-tomcat-8.5.24 and have the workspace in Eclipse configured and tomcat working properly.
I need though to do some debugging, but I dont know how can I enter debug mode in Eclipse with the tomcat running from cmd? I have done it several times in the past but I was always launching tomcat in debug mode from my IDE.
You would have to enable remote debugging on tomcat for which the following catalina property needs to be added in tomcat startup.sh or tomcat.start.sh or wherever you add tomcat startup properties:
CATALINA_OPTS="$CATALINA_OPTS
-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
Then restart tomcat.
After this is done, you need to open eclipse, and to go "Debug --> Debug Configurations -- type in the search box "remote java application", and create new, then select your module/java project which you want to debug and give the port number same as given in the above command (i.e. 8787 in the example above). Then Apply and launch.
While the other answer may solve someones problem, it didnt solve mine. Though the way i followed and solved my problem is:
First you start tomcat (all services up), and then you start the debug mode in eclipse!!!
For tomcat as i use the catalina.bat jpda run to start my tomcat i just edited it and used it as follows:
catalina.bat jpda run - agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
For eclipse:
1)In Eclipse’s menu, select Run > Debug Configurations…
2)A new Debug Configurations window will appear
3)In the list on the left, select Remote Java Application. Don’t worry
too much about the word “remote” here. It just means that the JVM
process can either be on the local machine or another machine across
the network.
4)Select New in the context menu (you can either right click to see
the option for it, or select the icon above the list)
5)A new Remote Java Application debug configuration window will appear
6)Change the Name field to say “Tomcat (local)”, or the name of your
web application, your choice. The name you put here can be anything,
but shorter is better because the name will show up in menus.
Eclipse Run Configuration for a separate Tomcat JVM
There are at least three subtabs of configuration: Connect, Source,
and Common. Under the Connect subtab, there is a Project field. Select
the Eclipse project that represents the code you want to debug. For
instance, if you want to debug your webapp, select your webapp’s
Eclipse project here.
All of the other default settings should be fine. You should probably
look through the settings to see if you would like to change any
options, just beware of changing settings if you aren’t sure what the
effect will be. Make sure that the port number you’re setting in the
Connect subtab is the same port number you configured your Tomcat
JVM’s debug server to listen on.
Click Apply, then click Debug. At that point, your Eclipse’s debugger
will connect to your Tomcat JVM’s debug server. Next, switch to the
Eclipse Debug perspective. In Eclipse’s menu, select Window > Open
Perspective > Debug.

How do I get the command-line for an Eclipse run configuration?

I have several JUnit run configurations in Eclipse that I need to replicate on the command-line in order to use a third-party analysis tool. So far I've just been writing the command-line manually by looking at the run configuration and writing the appropriate classpath and command-line arguments.
Eclipse's run configurations (normal, JUnit, or other) must ultimately boil down to a command-line anyway, so how and where do I find that?
I found a solution on Stack Overflow for Java program run configurations which also works for JUnit run configurations.
You can get the full command executed by your configuration on the
Debug tab, or more specifically the Debug view.
Run your application
Go to your Debug perspective
There should be an
entry in there (in the Debug View) for the app you've just executed
Right-click the node which references java.exe or javaw.exe and
select Properties In the dialog that pops up you'll see the Command
Line which includes all jars, parameters, etc
You'll find the junit launch commands in .metadata/.plugins/org.eclipse.debug.core/.launches, assuming your Eclipse works like mine does. The files are named {TestClass}.launch.
You will probably also need the .classpath file in the project directory that contains the test class.
Like the run configurations, they're XML files (even if they don't have an xml extension).
To elaborate on rob's answer.
Make sure you open the debug view. Steps to open it: Window -> Show View -> Other -> (Search debug) -> Open
Then do what he references:
Run your application
Go to your Debug perspective
There should be an entry in there (in the Debug View) for the app you've just executed
Right-click the node which references java.exe or javaw.exe and select Properties In the dialog that pops up you'll see the Command Line which includes all jars, parameters, etc
Scan your workspace .metadata directory for files called *.launch. I forget which plugin directory exactly holds these records, but it might even be the most basic org.eclipse.plugins.core one.

Find the command and options used by NetBeans IDE

I am using a the NetBeans 7.x IDE. I have a Netbeans Application module. I use the Build and the Run buttons from the IDE. The module runs just fine when I press Run Project or F6 button. I like to run
this from the command line. Since everything was build automatically for
me I have no idea where things are or how to run it. There are several jar files in the project/build/public-package-jars. Is there a way to see what command and options the Run Project is using ?
Go to the root of the application (or wherever there is a build.xml file) on the command line and run ant -p. That will list all of the available options for building and running the application.

How to repeatedly run Wicket/Maven/Jetty project in Eclipse?

Thanks to those info http://www.ralfebert.de/blog/wicket/wicket_eclipse_setup/ and How can I begin using Wicket? now I am able to edit Java code and html files with Eclipse, and run it to get Jetty started.
However there are still two problems which do not allow me to repeatedly run the project:
I have to stop previous run in order to run it again
unlike regular Java project, where I could simply choose "run", now I have to go into "Run Configuration", select Maven Build type, and below select my project to run, and then finally click "run"
ad.1. How to make Eclipse stop the previous run on next run -- i.e. I would like to just run project, and Eclipse should either run it, or stop previous one and run it again
ad.2. how to "bind" Run/Run to running my configuration (Maven Build / my project)?
Thank you in advance for help.
Another simply option is to use a Start class with a main that runs and embedded jetty. Then you will be able to run and debug your application as a normal desktop java application with your IDE.
Check the example start file that comes with the wicket quickstart here:
https://github.com/jordeu/wicket/blob/master/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java

Launch and debug a single script in PyDev

I am a beginner in using Eclipse and PyDev (Aptana Studio 3). I am not used to and i don't understand the workflow in such big IDEs as Eclipse.
I have a simple task: i have a simple Python script, which i want to open and run in Eclipse, having its output in Eclipse console. Or debug it.
Until now i used another IDE called Eric4, which allowed me to do what i want - open a file and run immediately, without creating a project or setting up launch configurations.
Is this possible in Eclipse, or i have to create a project for each file i want to run or debug? I want to understand how it works.
I guess i understand that creating a project is needed at least for settings up the paths (PYTHONPATH), but if it's a single script - somehow to use by default the current directory?
For example i have a folder called snippets where i keep a lot of python scripts which demonstrate some functionality. How do i open these files one by one and run them?
Most of my coworkers launch python scripts in a separate console - python my_scipt.py.
You need to have at least one project with the configuration you want (i.e.: syntax type, interpreter), then, open the file you want to run and press F9.
If it's an external file -- i.e.: a file that's not under a project in Eclipse -- it'll ask you to associate a project with the launch to get the needed information for the launch, but the file doesn't really have to be in the project (note that you can drag external files from your filesystem into Eclipse to open them).
I suggest you follow the steps on the getting started: http://pydev.org/manual_101_root.html (it guides you to configuring PyDev and explains how to do a run/debug session).