Eclipse ${project_name} expanded inconsistently - eclipse

I've been using Eclipse ${project_name} variable as a configuration class hack to determine which project is running.
VM args
-Dproject_name=${project_name} in the relevant JRE builder.
Code
String projectName = System.getProperty("project_name");
The problem is that projectName is inconsistent across different machines, and sometimes in the same machine.
Sometimes it is parsed into ${project_name}, sometimes into the the configuration project, and sometimes into the project calling the configuration.
We use Eclipse 3.6 and 3.71, if that's relevant.
Any ideas?

I have seen that the value of ${project_name} depends on the project that has currently the focus in the IDE. A project has a focus for example when one of its files is selected in the package explorer or one of its files is opened in an editor and the focus is on the editor.
Unfortunately it is not related to the project to which the started application belongs to, and I don't know an Eclipse variable that contains that project (although I'm also interested in a solution for this).
So as a workaround, make sure you are actually in the right project when you run the application from within Eclipse.

Related

How to make Eclipse show packages?

I recently upgraded my Eclipse and the workspace stopped working.
So I made a new one, copied all my projects over to it, then imported them.
However, now it shows them as folders instead of the actual packages like it used to:
How can I get the packages back?
Are you sure, you are using the Eclipse perspective Java or Java EE and within one of those perspectives, are using the view Package Explorer ?
Most of the times this happening because the Eclipse view Navigator is used, as show here.

Setting a default working directory in PyDev/LiClipse/Eclipse

I am using LiClipse / PyDev. When I run some test or other python module from the package explorer via right click -> run as -> python run, the working directory is set to the directory of the corresponding file, e.g. ${workspace_loc:MyProject/tests/misc}.
I want everything to be executed from the root folder of the project though. Under run configurations -> arguments, that folder can be selected via the button "default" which sets the working directory to ${project_loc:/selected project name}. Unfortunately the "default" button apparently is not selected by default, but instead the "other" option with the directory set as described above.
When having many test modules it becomes a little bit annoying to select this "default" button manually for each one. So how do I get LiClipse to actually select that button by default? Or to use the project directory as the working directory by default in some other way?
A similar question was already asked before, but without a satisfying answer: Configuring the working directory in Eclipse 3.8.1 with PyDev-project. The only conclusion was that an Eclipse bug does not allow to configure the value of the default option, which is not necessary for my purpose though. I only want this option to actually be selected.
The issue might be specific to PyDev, as it seems that Eclipse usually has the "default" option selected according to what I read.
Well, unfortunately, as you discovered, there's really no way to set that default in the IDE.
Still, to solve your problem related to tests, my suggestion would be using the pytest runner (you may have to install it -- instructions at: https://pytest.org/latest/getting-started.html and then set in the PyDev > PyUnit preferences the setting to use the pytest runner)... as a note, even if you won't be using the pytest way of writing tests (which I highly recommend), and using unittest.TestCase, it should work...
When running pytest, PyDev needs to follow a different logic because of how it deals and loads its fixtures which make it use always the same folder (I think it's the source folder, but if you're using the source folder and the project folder as the same it should work -- and if that's not the case, in pytest, it's trivial to create a session auto-use fixture which you could use to change the working directory to a given folder (with unittest.TestCase this is more difficult to do as you're constrained through your test class hierarchy, but you could also override the setUp of your tests to do that).

AspectJ causing "Editor does not contain a main type" error

After installing the AspectJ Development Tools into Eclipse, the "Run" button and the Ctrl-F11 shortcut both become nearly useless: using them (or the Debug button) will throw an "Editor does not contain a main type" error message, even for projects that do not require a main type to be present (eg. Android application projects). Standalone Java projects with a proper main type defined work fine - so it seems AJDT is forcing Eclipse to check for a Java main() without checking the project type first. Whether or not the project is an AspectJ project makes no difference, either.
The problem only appears when the file you are currently editing has either ".java", ".aj" or ".class" anywhere within its filename (note: it doesn't actually have to end with those extensions, as long as it's anywhere in there - readme.txt will work, readme.java.txt won't).
Two ways I've found to work around this - regardless of whether or not it's an AJ project - after installing AJDT is:
Select a file within your project in the Package Explorer whose name doesn't contain .java, .class or .aj, and then hit Run (the Package Explorer has to remain active and selected).
Create a new Run Configuration for your project, and use it to launch your project. This still adds a pointless extra step, as well as being impractical for those who work with a lot of projects.
I've tried this on both Eclipse Juno and Helios (Windows XP x86 as well as Win7 x64), the result is the same. While it might seem like nitpicking it certainly isn't: AJDT is hijacking the most frequently used function of the IDE.
I've resorted to having two different Eclipse installations with their own separate workspaces on my work PC, one with AJDT installed, and one without, so I can use the IDE properly when I'm not working on anything AJ-related. Since my company is working on a project that would require other developers to install AJDT into their IDEs, this is a significant issue for us that goes beyond our own loss of time - I can't imagine a lot of developers would be willing to put up with a significant bottleneck being added to their workflow for absolutely no reason at all. So most likely, they will just ditch our product instead!
Update: This has been identified to be a bug inside AspectJ, and has been reported to the AJ development team. You can keep track of it here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=399660
As of this writing, the bug has already been partially fixed, restoring Run functionality to non-AJ-enabled projects.
I was just coming on this site to ask the same question. While I don't have an answer for why this is going wrong, I have a workaround which is helping me currently:
Go to Preferences > Run/Debug > Launching and select Always launch the previously launched application. This will introduce bearable behaviour when working on a single project. You will need to manually create a run configuration for your main class.

Change in perspective name not appearing

I have a plugin in which I have created a perspective. Now I changed the name of the perspective in plugin.xml. It is working fine if I am running from sources. The name of the perspective still the older one when I export the plugin. I am using eclipse juno 4.2
I am completely lost no clue whatsoever. I checked the plugin.xml file in the exported plugin it is having the new name. What is the mistake I am making???
My problem was adding perspectives and views using the plugin.XML, changes didn't take effect because when running plugin projects in development environment eclipse creates a "runtime-(pluginProjectName).application" folder in the parent of the workspace directory.
If you delete this folder eclipse should run with the new changes made to Views and Perspectives structure.
Best of luck.
http://www.eclipsezone.com/eclipse/forums/t61566.html This link helped me in solving it. I should have searched in this line earlier itself. I hope this helps for someone else. Do clean your eclipse in case of these kind of problems

Eclipse project explorer prefixing latex project names with "P/"

Okay, this has been bugging me for quite some time today : Eclipse's Project Explorer adds a prefix "P/" to some of my projects' name. It happens only in the explorer, as everywhere else the project name appears normally.
I didn't manage to find anything relevant on the subject in the doc' and I don't really know how to google it.
I just reinstalled Eclipse's Platform Binary 3.7.2 along with the CDT and Texlipse plugins on Precise. The prefix "P/" appears only with texlipse projects, or when I open a .tex file inside any project.
So my question is : do you know what it means ? How to get rid or it ?
When you call toString() on a Project you get this. The leading P/ indicates it's a project (it's a convention of all of the Eclipse resources, F/ for file for example). This is probably a problem in the Texlipse plugin where the label provider that they provide to the Project Explorer (Common Nagivgator) is wrong, it's using just the project, instead of project.getName(). You should file a bug with them. There is nothing that you can do about it as a user.