How to run system shell/terminal inside Eclipse? - eclipse

I am using Eclipse Neon, and I would like to execute system commands on a shell/terminal, inside Eclipse.
In particular, I will need to open the system shell using the path of the current project folder on which I'm working in Eclipse.

In some Eclipse packages, like STS or Eclipse for JEE Developers, the Terminal is already installed in your IDE. If not, you can install the TM Terminal from the Eclipse */release update site, as you can see in the image below.
To open the command prompt (shell or terminal) using the path of a project directory inside Eclipse, you just need to select the folder, and press Ctrl+Alt+T, or right-click and select Show In Local Terminal > Terminal.
Then, the terminal will open in a new view inside Eclipse.

The Eclipse IDE which I am working there is no Terminal is there. So I needed to add the plug in like this and it works fine when you try clicking Alt+Ctrl+T
Click on Help in Eclipse-->Eclipse Marketplace--> in Find box (Search terminal and Enter)--> You will see TM Terminal 4.0 Version and just install it.
You may need to restart afterwards
And finally you will be able to get the Terminal when you will type
Alt+Ctrl+T on Console.

If you don't have the TM Terminal plugin installed, you could use external run configurations.
Click on the arrow near run button with the toolbox and add a new external run configuration.
Here, you can enter the path of your program(if you want to run commands, it will be C:\Windows\System32\cmd.exe (or the path to PowerShell on windows and /bin/bash (or similar if you use another shell) on linux.
In this dialog, you can also specify running directory of the application(the current project in your case)
After that, you can save this configuration and start it using the external run configuration menu(run button with toolbox)

Click on Run Cofiguration--> arguments --> Program Arguments (write any number of String) -->click on run

Go to Window > show view > Other.
A dialog will show up, type Terminal in the search field, select Terminal and click open.
A new empty view will show up in Eclipse.
On the top right corner of the view there is a button Labeled "open a Terminal".
Click on it, a dialog will show up
click OK and there you go, you got a Terminal.

Related

Is it possible to set which file to run by default in eclipse?

I'm writing a python project in Eclipse with the PyDev plug-in, which contains multiple files.
However I'm used to using visual studio, where it'll automatically find the main function of a project and run the program from there.
Eclipse will always run the file I am currently editing (which usually is a file containing function that are called from the main function).
Is it possible to set which file should be run then clicking run? I've looked at the launch options under Project->Properties->PyDev, but didn't find what I was looking for.
When you press the Debug or Run button (Debug on the left) Eclipse tries to intelligently determine what to launch based on your current editor.
You can change the behaviour by editing Window -> Preferences -> Run/Debug -> Launching -> Launch Operation as pictured below.
The default of launching the current editor works well for some languages, but not as well for Python when every single file is itself a valid program to run. In your case I recommend changing to Always launch the previously launched application.
You can create a custom run configuration.
Right click on your project > run as > run configurations
From here is just a matter of choosing your project type on the left hand side and filling in the required information. You can click 'Run' to use your new configuration.
To get to this configuration again, you can click the 'Run' drop down button in the eclipse tool bar and see all of your run configurations.
Hope this helps!

Golang on eclipse: "Resource doesn't have a corresponding Go package" on Mac

As stated in the title, I have a problem running the Golang code on Eclipse. I'm currently using Mac, and I installed go by using homebrew.
Currently, the folder where go is installed is as follows.
/usr/local/Cellar/go/1.5.2/..
and after running Terminal and typing open ~/.bash_profile I added the following.
export GOROOT="/usr/local/Cellar/go/1.5.2/"
export PATH=$PATH:$GOROOT/bin
Am I still missing something else?
PS If I run the code using Terminal like go run main.go, I have absolutely no problem. The problem must be due to some misconfiguration in Eclipse.
I had the same error. Putting the source file under a sub-folder in src fixed it.
Go to 'Run Configurations' -> Filter with Go Application -> select your project and then click the Environment tab, then click on select button and tick the GOPATH environment. select apply and then Run.
I had the same problem and I did two things to solve it:
I opened Run configurations, filtered using "Go" and created a new configuration (right click on "Go Application" as a result of the filter). In the Environment tab added a new variable: GOPATH = [path to your workspace].
I had .go files right under src folder, and this is wrong. I created a folder under src folder and moved .go files to that folder.
The first step could be replaced by creating a system environment and adding it to the list using the "Select" option instead of creating a new one. I prefered to create a new one so I can run differente projects in the same laptop without having to change the value of the system environment.
Because the executable path is not right.
GoClipse compiles source into $project/bin, so we must set GOPATH = $project
Select project > Alt+Enter > Go Compiler > Use project specific settings > Eclipse GOPATH
In my case of wiki tutorial, GOPATH = :/home/sovann/go/wiki.
Then the IDE is able to locate /home/sovann/go/wiki/bin/main

How to go to specific folder in Eclipse?

From Eclipse, how to go to the specific folder? I mean in windows, how to open a command line which corresponding to the folder or direct open the file explorer to open the corresponding folder?
You have to create an external tool with location ${env_var:SystemRoot}\explorer.exe (or cmd.exe) and arguments /select,${resource_loc} . Any selected file or directory can now be shown in the windows explorer.
Create an External tool
Go into the external tool configuration (you can find it into the corresponding toolbar icon) :
Then you can create your own external tool :
Create a new Program (select Program in the tree)
Name it shell
Set the location to ${env_var:SystemRoot}\explorer.exe
Set the arguments to /select,${resource_loc}
Run the external tool
Once created you can run the external tool from the context menu or from the toolbar ...
I have been using an Eclipse plugin called PathTools for sometime now, and am happy with it.
It adds a number of buttons to the Eclipse toolbar which allow you to :
Directly open a cmd prompt at the selected folder.
Open an Explorer window for the selected folder.
Update site : http://pathtools.googlecode.com/svn/trunk/PathToolsUpdateSite/site.xml
Sample screenshots
Installing the `Path Tools Feature`
I chose to install only the Path Tools Feature
Opening a terminal
Opening a terminal directly at the Folder Path :
(The above snapshot is that for OSX but works in Windows as well)
Opening Explorer
Opening a folder directly in Explorer/Finder :
Great simple plugin for this:
http://basti1302.github.com/startexplorer/
2019 update (no plugins required):
Right click the desired folder in the Project Explorer, go to Show In, choose either Terminal or System Explorer. See below screenshot:
Right click the file (in left pane).. then use Win Goodies -> Open file in Explorer

Open directory containing a source file via Eclipse

In Visual Studio, or MyEclipse, you have a button which is able to locate a source file on disk, and open the containing directory in Windows explorer.
This is useful, for example, to browse images, or to use an other tool when a conflict occurs in CVS or SVN.
What would be the way to do it in Eclipse with a free plugin, or without any plugin ?
I found it :
"In eclipse, it is common requirement to open the folder containing source file but there is no direct method to do that like in Visual studio of Microsoft."
http://shivasoft.in/blog/others/tips/locate-source-file-on-local-disc-in-eclipse-external-tool/
An actual plugin can be found at http://blog.samsonis.me/2009/02/open-explorer-plugin-for-eclipse/
And version 1.5 can be found here http://blog.samsonis.me/2011/08/openexplorer-eclipse-plugin-1-5-0/
One that I've since upgraded to & find more useful
http://basti1302.github.io/startexplorer/
I always do this:
right click on file/folder, show in..., system explorer. Done.
I guess we don't need a plugin to do that, or I am misunderstanding the question?? I am using Luna 4.4.2 on Windows 7.
On Mac you can follow this steps to add it without a plug-in:
Click the disclosure icon to the right of the External Tools icon:
Select External Tools Configuration:
The External Tools Configuration window will appear. Select Programs and then click New Launch Configuration:
This will create a new launch configuration. Enter a name of the configuration in the name field:
In the Location field enter the path to the Open Finder, "/usr/bin/open" without quotes:
In the Arguments field enter the following argument, "${container_loc}" with quotes:
Click Apply. It should look like the following:
Switch to the build tab and deselect Build before launch:
Switch to the Common tab and select the External Tools checkbox in Favorites. Click Apply again and close out of the window.
You are done. Now to use:
Select a file or folder in Eclipse Package Explorer.
Click the disclosure icon to the right of the External Tools icon:
Select the Open Containing Folder from the drop down menu:
You're file or folder should open in Finder.
PRO TIP: After you use the external tool once you can click the External Tools icon again and it will run the last used external tool. In other words, you won't need to select it from the pop up menu each time.
You can also look up the source directory by right clicking on the project, going to properties, and looking at "Location: ... "

Eclipse on Windows 7

Every time I open eclipse Galilio on Windows 7 64bit this message appear
and it won't work
-------------------------------------------------------------------------------------
Faild to load the JNI shared library "C:\Program Files(x86)\java\jre6\client\jvm.dll"
-------------------------------------------------------------------------------------
Help me please.
If you are using the 64-bit distribution of Galileo, you need a 64bit distribution of JRE (not a 32bit installed in "C:\Program Files(x86)").
If not (you are using a 32bit) version, you can (as in this thread),
Check your path variable,
make sure that if you type "java -version" at a command prompt you get the version you expect.
Or better yet, edit your eclipse.ini file to specify a particular JVM location.
See http://wiki.eclipse.org/Eclipse.ini for examples.
Now check out what's below. This should help you fix your Eclipse issue with Java and Windows 7 64-bit.
Eclipse will not open when the exe is clicked on Windows 7 64-bit OS.
Eclipse Standard/SDK
Version: Kepler Release
Build ID: 2013614-0229
This is for the Firefox v22 64-bit browser
OS: Windows OS 64-bit
Okay, you assume that Java is set properly on your Windows 64-bit PC and you've loaded Eclipse in a folder on your desktop. You've also created a separate folder called Eclipse Workspace which also resides on the desktop. Now you're ready to go and then in the Eclipse/Eclipse directory you click the Eclipse.exe and then you get this janky error message after the Eclipse window opens:
"Java was started but returned exit code=1" (with other related data)
or ------->
You clicked the Eclipse.exe file and this message was displayed: "A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java Virtual Machine was found after sending the following locations: c:\Program Files (x86)\Java\jre7\javaw.exe" or something like this. Now I'm not saying that this solution will work for everyone but note that this is a good baseline starting point to find out your solution.
--- or ---
2b. In DOS, you typed Java or java -version in the command line, pressed then this error was thrown:
"Picked up_Java_options:
-Xrunjvmhook -Xbootclasspath/a:C"\Program~2\hp\Quickt~1\bin\Java_S~1\classes;c:\Progra~2\hp\Quickt~1\bin\Java_S~1\classes\jasmine.jar
Error occurred during initialization fo VM could not find agent library JVMhook on the library path; with error" Can't find dependent libraries..."
* Again, keep in mind, this process is being done with the FireFox v22 64-bit browser** If using this browser, you need to check the following, to see if Java is enabled in the browser. I know what you're thinking but just do it!
Open or maximize the Firefox browser.
At the top left of the page, click Tools then the Add-ons option.
Click the Plugins option in the left pane.
You should see:
Java Development Toolkit 7.0.250.17 10.25.2.17 NPRuntime Script Plug-in Library for
Java (TM) Deploy. (or a plugin with a relevant version number)
Look to the right and make sure this plugin is Enabled~! If it is not Enabled, enable it!
If you do not see this plugin, at the top of this page, enter "Java" in the Search All Add-ons field, locate the plugin then install it.
Now go to Java.com and download the current version of Java for 64-bit. You need a JRE (Java Runtime Environment) and a JDK (Java Development Kit files and both have to be 64-bit!!!!!!! Once downloaded run both. They usually sit at either of these locations with these path distinctions:
c:\Program Files\Java\jre7 (This is the location of the JRE=Java Runtime Environment)
c:\Program Files\Java\jdk1.7.0_25 (This is the location of the JDK=Java Development Kit)
--- or ---
c:\Program Files (x86)\Java\jre7 (This is the location of the JRE=Java Runtime Environment)
c:\Program Files (x86)\Java\jdk1.7.0_25 (This is the location of the JDK=Java Development Kit)
* Now keep in the these version numbers will change but here are the preferred locations.
Environment Variables Edits
Click Windows Start button (bottom left on Windows 7) then click Computer.
At the upper left, click System Properties. The Control Panel Home window opens.
Click the Advanced System Settings option.
Your User Account Control window may open.
Click the [Yes] button.
The Systems Properties window opens.
Click the [Environment Variables] button.
Go to the User Variables for (Your System Name here).
Delete everything here accept, the following:
PATH
TEMP
TMP
Now highlight the PATH variable and then click the [Edit] button.
The Edit User Variable window opens.
You want to add the following:
;c:\users\Your User Name\desktop\eclipse\eclipse\jre\bin;c:\Program Files (x86)\Java
\jre\bin;c:\Program Files (x86)\jre7\;c:\Program Files (x86)\Java\jdk1.7.0_25\bin
Click the [OK] button and the Edit User Variable window closes.
Now go to the System Variables section.
Delete all the Variables accept the following:
asl.log
CLASSPATH
Comspec
FP_NO_HOST_C...
NUMBER_Of_P...
OnlineServices
OD
PATH
PATHTEXT
PCBRANDS
Platform
PROCESSOR_A...
PROCESSOR_id...
PROCESSOR_LE...
PROCESSOR_R...
PSModulePath
TEMP
TERM
TMP
USERNAME
Click the [New...] button.
The New System Variable window opens.
In the Variable Name field (which the cursor is currently blinking in...), enter JAVA_HOME.
Then go to the Variable Value field and enter c:\Program Files (x86)\Java\jdk1.7.0_25\bin;%JAVA_HOME%/bin.(Without the period, of course!)
Click the [OK] button and the New System Variable window closes.
Now highlight the PATH option and click the [Edit...] button.
The Edit System Variable window opens.
Go to the Variable value field and add the following at the end of the string already there:
;c:\Users\Your username here\desktop\eclipse\eclipse\jre\bin;c:\Program Files
(x86)\Java\jre7\;c:\Program Files (x86)\Java \jdk1.7.0_25\bin
Click the [OK] button and the Edit System Variable window closes.
Click the [OK] button to close the Environment Variables window.
Click the [OK] button to close the System Properties window.
Now for the Pista Resistance!!!!!!! Go back to the Eclipse folder on your desktop (or alternative location), then click open. Now download Notepad ++ from http://notepad-plus-plus.com and install it.
Use Notepad ++ to open the eclipse.ini file from the Eclipse folder. Using Notepad ++ keeps the eclipse.ini file's format correct.
With the eclipse.ini file opened with Notepad ++, look for -- launcher.append Vmargs. Once you've found this entry, place the cursor after it and then press . You should now see a space.
In that space enter the following: (and this must be entered exactly like what's listed below)
-vm
c:\Program Files (x86)\Java\jre7\bin\
c:\Program Files (x86)\Java\jdk1.7.0_25\bin
Now click File then Save as, with the file name as Eclipse.ini, then click the [Save] button.
A message box will display asking "Do you want to replace the file?", click the [Yes] button.
Now click File then Exit and Notepad ++ closes.
Now close then restart the Firefox browser.
Now close then reopen the Eclipse folder. ( I know what you're thinking but just listen and nod and do it.)
Click the Eclipse.exe file and now you should see the Eclipse splash screen.
After a few seconds, a message displays asking you to select an Eclipse Workspace. You should have this Workspace on your desktop
or some where you can make this connection.
Now Eclipse is working! Let me know if this process worked for you!