PyDev throws NPE During Sync SystemPYTHONPATH - java

I have an RCP app built with PYDEV in it, and every time I launch it, if there is one or more interpreters cnfigured, PyDev throws a NullPointerException while running the Sync System PYTHONPATH job. It will do this if I manually check the synchronization by clicking the button on the PyDev/Interpreters preference page, or if PyDev does the automatic sync check within one minute of starting.
It does this if I configure any interpreter. When I configure the same interpreter in the Eclipse IDE itself, I don't get the NPE. So something in my RCP app is causing PyDev to throw this error, but I don't have any idea what else I need to do to use PyDev in the app.
The NPE occurs at SynchSystemModulesManager lie 391, using PyDev 4.2.0

The builder that was supposed to be contributed via an extension point was null. This led me to realize that I was missing some required plugins in the eclipse run config and in the Maven build. The problem was solved by making sure that all dependencies of org.python.pydev were included in the product.

Another solution is to implement the required extension, it does not have to do anything.
Add the extension to your plugin.xml:
<extension
point="org.python.pydev.pydev_interpreter_info_builder">
<interpreter_info_builder_participant
class="org.example.InterpreterInfoBuilderParticipant">
</interpreter_info_builder_participant>
Then add the class:
public class InterpreterInfoBuilderParticipant implements IInterpreterInfoBuilder {
#Override
public BuilderResult syncInfoToPythonPath(IProgressMonitor arg0, InterpreterInfo arg1) {
// Do nothing
return null;
}
}

Related

IntelliJ Idea Completion Error

I am new to Idea IDE. After installed it for a few days, I was fascinated with its outstanding features.
However, while I was actually writing code yesterday. I discovered that when the auto completion popped out, it showed nothing about the method of the object , merely some basic template say sync() var() ..... etc.
I have tried to setup the environment (Check the power save ...etc), but those previous solution seems to be for those whose auto-completion is turned off . Is there a way to fix it ?
THANKS IN ADVANCE!!
When you have create your project, you might not have marked it as a Java project and provide a SDK.
You can check it in File -> Project Settings -> Project -> Project SDK.
If not, you can download the JDK on the Oracle site http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
You can also try to write a
public static void main(String... args) {
System.out.println("It works !");
}
and write click on the "main" word. You should have a "Run 'Main'" option.

Do not save workbench state in a eclipse RCP app

I am devoloping an application with eclipse RCP. This application should alwaysshow a certain perspective when started. But the application saves it workbench state and when restarted it shows the same perspective it had when it was closed. I tried to add
public void initialize(IWorkbenchConfigurer configurer){
configurer.setSaveAndRestore(false);
}
to my ApplicationWorkbenchAdvisor class, but it did'nt work. I also thought of selection the right perspective, but I don't know where to add such a piece of code.
How can my application always show the same perspective on startup?
Too late for you but maybe usefull for other people.
As #Aiden says, we add -clearPersistedState to the program arguments in run configurations.
It worked for us in e4 with Eclipse Neon 4.6.
I found out that if you always want the same start perspective, you can set the default perspective during startup.
public class Application implements IApplication {
public Object start(IApplicationContext content){
PlatformUI.getWorkbench().getPerspectiveRegistry().setDefaultPerspective("youperspective here");
//other code...
}
//other code...
}
UPDATE:
This only works if you enable "Clear workspace" in your run configurations. My current solution is to delete the workbench file during program startup.

Start Gradle from Java and run it in same JVM as main program

I have an Eclipse plug-in which has to start a Gradle build script. I currently use the SpringSource Eclipse plug-in for that. Here is my code:
public void run(String project, String task) throws FastOperationFailedException, CoreException {
File projectLocation = new File(project).getAbsoluteFile();
GradleProject gradleProject = GradleCore.create(projectLocation);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
System.out.println("MyWorkspace1: " + workspace.toString());
TaskUtil.execute(gradleProject, null, Arrays.asList("mytask"), new NullProgressMonitor());
}
This code works fine. The Gradle process is started and does its duties. However, Gradle is started in a new JVM. I would need to pass objects between my plug-in and the Gradle process, so I would need to have them run on the same JVM. Does anyone know if this is possible or if I could pass objects to Gradle without serializing them?
Update
The overall idea is to create a way to pass the IJavaProjet to Gradle. MoDisco is a tool for model-driven reverse engineering and I need to call it as part of my builtd script. It only oprrates on IJavaProject instances, which can be easily retrieved inside the Eclipse JVM but are hard to get otherwise. So to sum it up, I would need to:
create a IJavaProject inside the Eclise plug-in
pass it to gradle, which woud start MoDisco as a task
perform some other EMF operations on the result of the above task
(optionally) return the object back to my Eclipse plug-in

How do you debug a problem in the Activator of an Eclipse plug-in?

I am trying to follow an OSGi bundle tutorial (http://www.vogella.de/articles/OSGi/article.html). It includes this method in the Activator class:
public void start(BundleContext context) throws Exception {
System.out.println("Starting de.vogella.osgi.firstbundle");
}
public void stop(BundleContext context) throws Exception {
System.out.println("Stopping de.vogella.osgi.firstbundle");
}
Unfortunately, the println statements don't print even though the tutorial writer expects them to print. I am obviously new to OSGi and Eclipse, so I am quite lost. Can someone help me along?
Well, I said I was confused. The tutorial mentioned above runs the first demo in Eclipse, but quickly shifts to a standalone container. I got that to work, but broke off for the night and when I came back in the morning started using the built-in OSGi console to follow the standalone instructions. This doesn't work very well and results in the odd behavior described above. When I went back to the standalone container as directed in the tutorial it works better.
I'd assume your plugin isn't even started, or eclipse has no reasons to load your plugin (eclipse does lazy loading of plugins so activate a view of your plugin or something).
If it's the first problem make sure that under Run Configurations->Plugins "Launch with all workspace and enabled Plugins" is selected (that's the easiest to make sure that the plugin and its dependencies are all loaded).

Running multiple launch configurations at once

I have several launch configurations in Eclipse each launching the same Java program but with different parameters.
Now is it possible to run all of these at once (with one mouse click) instead of selecting each of it separately and launching it?
EDIT: According to this answer since Eclipse Oxygen (4.7.0) you can use a run configuration of the type Launch Group for that.
Just install "C/C++ Development Tools" from the CDT (see eclipse.org/cdt/downloads.php ) - this single package is enough, no other CDT packages are needed. This won't disturb your Java environment ;-) Then you have "Launch Groups", for any kind of project, including Java projects. See the following screenshot:
You can run or debug the projects (also mixed mode), define delay times and so on. Have fun!
I found this post on the Eclipse trackers: Start multiple debug configurations at once
While it talks about multi-launching debug configurations, I think it is just as applicable to run configurations.
You may want to right click a run configuration in group launch and configure it.
Since Eclipse Oxygen (4.7.0) you can use a run configuration of the type Launch Group for that.
This short video shows how to use a Launch Group.
There are two more options listed in Launch an Eclipse Run Configuration from ANT.
You could group them in Ant and then call them using Ant4Eclipse. Or call multiple launch configs from a command script using eclipse remote control.
You can create a separate class that calls your program with different arguments, and run it instead.
public class YourClass {
public static void main(String arg){
System.out.println(arg);
}
}
public class YourClassTester {
public static void main(String[] args){
YourClass.main("SomeArg1");
YourClass.main("SomeArg2");
YourClass.main("SomeArg3");
}
}
You don't need any plugin:
Create all Run Configurations in eclipse
Select Organize Favorites...
Add you favorites, done

Categories

Resources