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).
Related
I am just learning Java and use Eclipse. I have a question that I can not find an answer to.
Why does eclipse require me to use a project? I am using eclipse now to learn Java,
and that means compiling my source.
Problem being that when I add another source file Eclipse
compiles both applications. This means (and I could be very wrong here) I need to create a project
for every new program I write.
Why can I not just create and compile programs without a project?
What are you missing is called 'Run Configurations'.
Create a project.
Write your multiple programs within this one project. (Presumably, these programs might share some class files or other resources.)
Each of your programs will contain a class file with an entry point, for example, a main() method.
Open this class file and right-click. Select 'Run As', then the most appropriate option.
Following this you will see your Run Configurations here:
Click the drop-down icon and select the Run Configuration that you want to execute. Select 'Run Configurations...' if you want to add program arguments or making other changes.
I am just starting to consider using Eclipse, as I hear it is a very good debugging tool and excellent IDE. I have a .java file which I had written in JCreator and have saved in my Google Drive directory. However, I am having problems running this file within Eclipse. If I open Eclipse and then open my file, a few things happen. First, a .metadata folder appears inside my Google Drive. Second, the file opens, and I can edit and save changes. However, if I try to compile the file, I get a "Run As" popup window with the options "Ant Build" and "Ant Build..." Selecting either results in a "Build Failed" error.
I have a few questions:
1) What is the .metadata folder and why does Eclipse create it?
2) How do I open an existing .java file in Eclipse?
3) What is an "Ant Build"?
Sorry if these questions are very basic, but a search through online tutorials has only told me how to create and compile projects with Eclipse. If I start a project in Eclipse, then everything works fine, but otherwise, I can't get anything to work at all.
I do not know, but a simple Google search led me to this question and this other question which might be of help;
I don't know if it is possible to just open a file without starting a project, but once a project has been started, it is relatively easy to import a file: File>Import, find the directory, check the files you want to import, select import directory and go ahead. Now I haven't managed to run a program with GUI after importing because apparently it has problems loading classes like JFrame because of a restriction in the library, but I have imported and run a simpler program; oh, and when you import, you select General, then File System;
Try googling for Ant Build. I fount a few sites mentioning "Apache Ant", which seems to be related to GUI building.
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.
I am trying to set up a project in Eclipse Indigo with pydev on windows 7 Pro SP1 x64. The project exists in my drive (downloaded via tortoise svn) and has the following structure :
root\
launcher.pyw
settings.ini
modules\
__init__.py
module1.py
module2.py
...
more_modules\
__init__.py
moduleA.py
moduleB.py
...
compiled\
1.dll
2.dll
...
I have successfully imported the project in eclipse - specifying root/ as the project folder - and when I right click on the launcher.pyw and run the file the program runs alright (it is a gui application). I have 2 (main) issues :
I want to be able to run the project normally (tell eclipse that when I run the project I actually mean run the launcher.pyw) - when I right click on the project > Run as > Python-unit-test is the only option
I have, say, in more_modules\moduleA.py something like from .. import module1 which shows as an error - so how should I set it up correctly ?
Not sure about the dlls folder also - and not sure about the code analysis - aparently I have to open a file to see the errors - but those belong to another question maybe
The project sourceforge page is : http://oblivionworks.svn.sourceforge.net/viewvc/oblivionworks/Programs/Wrye%20Bash/
The root/ is Mopy/
Edit: moved the picture from my comment:
Regarding launching, you can simply open the file and press F9 to run it. After that, if you've set to rerun the last launch in the preferences (see instructions at: http://pydev.org/manual_101_run.html), you can simply press Ctrl+F11 to rerun it.
I took a look at your sf page and noted you didn't commit the .project and .pydevproject files (please do, so that anyone using PyDev can get things configured directly).
Regarding your import error in the code analysis, it'd be nice if you can actually provide the real example (from your description the error is that you have a '.py' in the end of the module that probably shouldn't be there, but it may be just a description... if it runs and code-analysis doesn't get it, please create a project with that use case and attach it in a bug-report in the pydev sf tracker).
As for the code analysis, usually you really have to open a file to see errors, but you can also right-click a folder and choose pydev > code analysis and it'll do a code-analysis for all the files beneath that folder that are a part of your pythonpath.
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.