STS (Spring Tools Suite) writes STS.ini any time I get updated, merging with my own configuration - eclipse

To improve my STS performance I've added some parameters to STS.ini. But every time I update the tool, it puts its own configuration at the beginning of STS.ini file, relegating my configuration to the end, sometimes duplicating several parameters.
Is there another way to avoid this?
Now, everytime I update the tool I need to backup the file and check the parameters...

I tend to launch Eclipse and STS from the command line. I create a bunch of shell scripts, one for each variant of Eclipse/STS that I run. This ensures that every launch has precisely the arguments that I need.
For example, I have a bunch of scripts like this:
[21:09] ~/Eclipse
$ more eclipse_42.sh
Installations/Eclipse4.2.M6/Eclipse -data \
"/users/Andrew/Eclipse/Workspaces/workspace_42" \
-vmargs -Xmx1024M -XX:PermSize=64M -XX:MaxPermSize=256M
I like running from a terminal so that you can see what gets sent to sysout. And this could also be launched from a Finder window.
I run on Mac, but you could do something similar on Linux or Windows.

Just thought of another possible answer. I haven't tried this, but it could work.
Instead of doing "Check for updates", go to the install manager Help -> Install new software...
With the STS update site, select all the components that you want updated (except SpringSource Tool suite (required) and SpringSource Tool Suite Package (if you see it)).
I think it is these two components that alter the STS.ini. The only thing that I am not sure of is if it is at all possible to update individual components without updating that package.

Related

Cannot launch multiple instances of Eclipse Juno

I have multiple Eclipse versions installed in different locations (F:/eclipse-indigo, F:/eclipse-ganymede, F:/eclipse-juno). Indigo and ganymede allow me to launch multiple instances as long as I choose a different workspace. When launching a second instance of Juno I get the error stating "Java was started but returned exit code=1".
I've search for the error but most solutions were for OP not being able to launch Juno at all.
I can launch one instance fine but the second instance doesn't even allow me to choose a different workspace.
Just the error message above.
Try in this order:
Update your Java installation to a recent version. There are bugs in older Java versions causing similar problems: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7002666
Explicitly set the -vm argument in eclipse.ini to point to the Java installation that you want to use (in case there are multiple). Your Eclipse installation currently uses whatever Java was last installed (as that one copied itself into the system32 folder, from where it is started according to the error message).
Compare the eclipse.ini of Juno and one other version. Ignore the DLL and file names, but look if you changed some of the vm options (like memory size) in your old installation. If so, copy those settings into your Juno eclipse.ini.
Have you tried to start Juno explicitly by giving the workspace as argument like in the following shortcut:
F:\eclipse-juno\eclipse\eclipse.exe -data F:\eclipse-juno\ws1
If that does work, there is something wrong (in Juno) with selecting the workspace at the beginning. I try all the time to be explicit with which workspace I want to run Eclipse by creating a batch file or shortcut command like the above.
See this answer for typical command line options.

Upgrading STS with all plugins and settings

I was always disappointed when I have to update Springsource Toolsuite (would also apply to Eclipse, but I never had so much update issues with it), because it takes a rather long amount of time and update function inside of STS doesn't work that well. For example it was not possible for me to upgrade from 2.9.1 to 2.9.2, so I was forced to a reinstallation. In this question I want to show how I do this and I am hoping to get some feedback to improve this process:
I always ensure that I have this plugin installed from the market: P2 Installation Replication. It allows me to select and dump all my plugin info into a single XML file. So I start the old version of STS and dump my plugin list to a file with date in the file name to have different versions.
Then I close STS and rename the root directory to something like "springsource_old"
I download the new version as ZIP file and extract it in a single directory.
I use Lombok, so I download it and doubleclick on the JAR to install it for the chosen STS install location. Normally Lombok finds the installation if you stick to C:\springsource\.. or similar default locations.
Next I update the STS.INI file to force STS to use a specific version of the Java SDK with the -vm flag. If you have a lot of eclipse workspaces to manage it is also helpful to have them shown in the title bar of the window. So I include -showlocation in the INI file. It doesn’t have to appear first, just before -vmargs so that it doesn’t appear to be a JVM argument.
Then I start STS, choose the first workspace and close it again. This generates some preference files. What I want to have is the list of all workspaces. STS (Eclipse) is storing the workspace information in a preferences file called "org.eclipse.ui.ide.prefs".
This file is located under "%ECLIPSE_HOME%\configuration.settings" and contains a key named "RECENT_WORKSPACES". So open the file in the backup location, copy the entries, open the new generated file, and copy the settings into it. The next time I start STS, I can choose between all previous used workspaces again.
Even when no plugin is installed, STS (Eclipse) can natively open the files with the dumped plugins from step 1 (Import - Install - Install Software Items from File). It also allows to fetch the latest version instead of the version which was saved in the XML file. So I select and fetch all my missing plugins.
What is still missing from your experience? How could I improve this process? It still takes some time.
Update
Can't be that I am the only one who has problems with updating STS. Today the update from 3.1.0 to 3.2.0 came and now my STS looks like:
So I still have the issue that after every major update STS is not working anymore.
What exactly was the problem that you had? In general, you should be able to upgrade from a point release to the next point release with no problems (eg- from 2.9.1 to 2.9.2).
There was a problem at one point, which prevented you from upgrading, but that is fixed now. See here: http://forum.springsource.org/showthread.php?126775-Cannot-update-Grails-Support-from-2-9-1-to-2-9-2&p=413794#post413794
If you are having troubles upgrading, please post to the STS forum and paste the error that p2 is giving you with your message.
Sometimes, when upgrading you can look at the error message and see what component is not being found. You may need to add a new update site or de-select an incompatible feature.

How can I clean up Eclipse "run configurations"

I set my java runtime options in Eclipse's Window > Prefs > Java > Installed JREs > Default VM Arguments. Since this setting is sufficient for all my main() entry points, I do not bother with customizing the "run configurations". It looks like nice flexibility but I probably will never need it. I was worried that I would have to repeat my VM arguments in the run configurations and so I started to copy my VM arguments but after an experiment it seems that I do not have to. Now I will have the opposite worry that I have some unintended customizations.
To eliminate the second worry, is there a way to eliminate the clutter visible in the Run drop down menu? What about the "Launch configurations" visible in the JAR export dialog? Is a run configuration the same thing as a launch configuration? How do I eliminate the multiple launch configurations?
I am on Eclipse Indigo on Ubuntu.
Edit After I manually delete all the run configurations, and proceed to do an export, buttons are greyed-out so I can't proceed. When I select the launch configuration drop-down, I end up with only one choice, from an unrelated project. I then created a run configuration for the real main entry point for the current project. I expect the clutter will return as I continue to use Eclipse.
One simple way would be to organize your projects by Eclipse workspace, which would limit the "run configurations" list only to the project referenced in a given workspace.
Switching workspaces would reset that list to the ones recorded for the projects of the new workspace.
Note: the OP's answer regarding launches file location isn't the only location possible.
The official one is:
${WORKSPACE}/.metadata/.plugins/org.eclipse.debug.core/.launches
But you can copy them enywhere else you want (as explained in "How do I save Eclipse launch profiles across workspaces?"), either by manually copying those files or by sharing them:
See "Which eclipse files belong under Version Control".
Once you know where they are saved, a simple delete is enough to make them disappear from the launcher menu.
The answer comes from #Francisco Puga
Experimental evidence shows that deleting "launches" seems to make run configurations disappear so it would seem that they might be synonymous.

How to make eclipse launch a program in the eclipse workbench from the command line?

How do I make eclipse launch a program in the eclipse workbench from the command line?
Specifically, I would like to run a command from the shell that causes my eclipse instance (which is already open) to run a particular program. If there is no program to do this from the shell, is there some RPC API that eclipse provides to make such a program?
I do not want to make a plugin. It must be a separate process that controls eclipse.
Eclipse Remote Control seems that it might do the trick https://github.com/marook/eclipse-remote-control from the Read me file.
Introduction
Eclipse plug-in project which adds remote control features to eclipse.
Commands can be sent via the eclipse remote control client to a
running eclipse instance.
I have not tried it myslef but I ran into it trying to figure out how to write an ant task that triggers .launch file
First create a batch file and save it in a location.
For example if I want to invoke notepad , I will write in the batch as follows
start notepad
In eclipse, you can configure external tools.
Goto Run -> External Tools -> External Tools Configurations.
You will be presented with a Dialog box.
Now Click on the New Configuration Icon.
In the right pane of Window you can assign a configuration Name.
In the Location Text Box, Click on the "Browse File System" Button, and select the batch file you have created earlier.
In the Common Tab, uncheck "Launch In Background".
You can set this configuration in Favourites menu, by clicking the checkbox "External Tools" under Common Tab.
Click on Apply.
Now you can Run your required application. This is for Windows only. I don't have any idea of this for Linux Machines.
Take a look at Product Configuration
1º Create a new Product Configuration (Ctrl+N), and select "Use a launch configuration" (or another option, if it's more convenient) on the first page of the wizard.
2º In the Exporting section you should be able to export your product using the "Eclipse Product export wizard".
3º To run the product, follow this instructions
Hope it helps.
Not a complete answer, but here are some things I've come across with Eclipse:
In general, you can open Eclipse from the command line with something like:
java -Dosgi.requiredJavaVersion=1.5 -Dhelp.lucene.tokenizer=standard -Xms40m -Xmx512m -XX:MaxPermSize=256m -cp plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar org.eclipse.core.launcher.Main
That Main launcher takes an -application flag where you can pass what I think are plugins (not sure). I've typically used this to run Ant within Eclipse:
java -Dosgi.requiredJavaVersion=1.5 -Dhelp.lucene.tokenizer=standard -Xms40m -Xmx512m -XX:MaxPermSize=256m -cp plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar org.eclipse.core.launcher.Main -application org.eclipse.ant.core.antRunner -buildfile build.xml
I have no idea how to manipulate a running Eclipse instance, and I don't know if you can achieve your goals through an Ant script, but I thought these might be fruitful avenues.
Addition to ams' answer, marook's plugin just support very few commands.
open_file and execute_command with RUN/DEBUG/PROFILE
And marook also have a blog post about how to implement more command http://pielmeier.blogspot.com/2010/07/implementing-new-eclipse-remote-control.html
But as we all know, Eclipse plugin development is quite heavy weight.
So, I suggest just use execute_command with RUN by marook's plugin. The further function to Eclipse IDE, can be done by Eclipse EASE script engine. Write a light weight script and then RUN by marook's plugin, to avoid Eclipse plugin development.
More information about EASE can be found at:
https://opensource.com/life/16/2/how-use-python-hack-your-ide
There is also javascript script support:
https://git.eclipse.org/c/ease/org.eclipse.ease.scripts.git/tree/JavaScript%20Beginner%20Tutorial/02%20File%20IO/05%20Create%20sample%20project%20(using%20modules).js
Here you have a series of examples: http://www.rgagnon.com/javadetails/java-0014.html
Basically, you use:
Runtime.getRuntime().exec(command);

Specific plugins per workspace

I came across this post and wondered if there is a way to activate only a few of all of my installed plugins depending on the workspace I currently work in.
For example - If I organized my workspaces like this
/workspaces
/java
/jee
/php
...
I don't need the Android-Plugin if I'm working on my Java EE-Projects and so on.
I also came accross this, suggesting to deactivate some capabilities for each workspace. But this not an option, as apparently no plugin is registered as capability.
Thanks, m
Edit: BTW, I am using Eclipse 3.5 Galileo
Maybe you can achieve your goal but it needs lots of "customization work" so I would not do it for myself :)
Create a "minimal" Eclipse install with plugins you use all of your workspaces.
Create one dropins folder for every workspace and put all of your "workspace-specific plugins" into that folder.
Create an Eclipse shortcut for all workspaces and use something like "-data _workspacedir_ -vmargs -Dorg.eclipse.equinox.p2.reconciler.dropins.directory=_dropindir_" in the shortcut.
Start eclipse with one of your new shortcuts.
Note that in this case you cannot switch workspace within Eclipse, you have to close the current one and start the new one using the corresponding shortcut.
UPDATE: I have found some Eclipse feature request for making this kind of setup easier if they will be implemented:
Software Update must allow to install plug-ins into extension location
Support for multiple bundle pools
You can use a different configuration folder for each Eclipse instance using the -configuration option when starting Eclipse.
On Windows, I would use a batch file (e.g. run-eclipse.cmd) which looks a bit like this (a bit different on Unix, more complex on OS X because of the app packaging):
eclipsec.exe -clean -configuration configs/%1/configuration
Execute it with your environment ID (e.g. run-eclipse.cmd java). I use eclipsec because I need the console output, but you can use the plain eclipse.exe executable. The -clean is not mandatory either.
Under my Eclipse installation folder, I will have a configs folder and under this folder I will have multiple configurations. Each config folder can have its' own plugins and folders. AFAIK, if you install plugins they will be installed in your configuration folder and not your main installation folder.
The structure you get is like this:
Eclipse Folder
plugins
features
configs
java
plugins
features
configuration
Eclipse plugins are expected to start only as needed, in a lazy manner. I'm not saying that all behave exactly that way, but if you write your own plugin, you'll see this is how the technology works, your plugin gets called only as needed.
So in Eclipse, if you configure your starting Perspective (Java for me) to have only the Views you need, the plugins that are used for other views should not be started.
To do this, take the view away and save your perspective (Windows - Save perspective as).
In addition, in Ganymede, in Windows - Preferences - General - Startup and Shutdown,
there is a list of plugins that should be started on startup, so you can edit that list.
I didn't try to see if this works per workspace though.
Although my solution won't let you install plugins per workspace but will solve the problem.
The best way i found to do this is using different eclipse copies:
Extract officialeclipse.zip to two different places and install plugins you like per eclipse.
A bit late answer but if you want to manage many workspaces shortcut the following tool is very simple and helpful : http://www.xdreamteam.ch/downloads/eclipselauncher/
I use it for sorting my projects by customers and workspaces, and it launch the right workspace with all the necessary configurations needed for each.