embeddedlinux-jvmdebugger-intellij icon indicating copy to clipboard operation
embeddedlinux-jvmdebugger-intellij copied to clipboard

Running a command before launch

Open rozling opened this issue 9 years ago • 9 comments

Almost got this great plugin working but am failing at the last step:

When deploying a Processing GUI app to the Pi, Processing complains with the following:

Cannot run sketch without a display. Read this for possible solutions: https://github.com/processing/processing/wiki/Running-without-a-Display

This can be resolved by setting an environment variable just before the Java command is run, however there's no option in Run/Debug configuration to do this.

On OSX it's proving difficult to find any config file to modify the deploy/build scripts. Is this possible to do, & if so where are they located?

rozling avatar Oct 08 '16 16:10 rozling

I believe what you're trying to do can be achieved by adding a Before launch step.

Run/Debug Configuration > Before launch > Add > Run Remote External Tool > Add

You should be able to point it to a script changing env var and execute it before launch.

BartoszKaszewczuk avatar Nov 11 '16 03:11 BartoszKaszewczuk

@BartoszKaszewczuk thanks for answering that one.

asebak avatar Nov 29 '16 12:11 asebak

The answer by @BartoszKaszewczuk doesn't work if you need to set an environment variable on the Raspberry Pi. In my case I need to set the DISPLAY environment variable to ":0" just before the program is launched on the target in the same SSH session. The "Run Remote External Tool" seems to run on a new SSH session.

scherpbier avatar Feb 18 '17 00:02 scherpbier

I have the same issue. Does anyone have a solution yet?

robbederks avatar Feb 27 '17 19:02 robbederks

Hello,

I am new to developing on java for RaspberryPi. I am using this plugin on Windows Intellij 2017 and the set up was very easy, so far it has been working great.

I have a screen connected to my RaspberryPi and would like to create a simple UI application that I can launch and debug from my Windows machine. However i get the error Exception in thread "main" java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. Is there a way to set up the plugin so I can debug UI applications on the PI ?

LucosidE avatar Apr 23 '17 05:04 LucosidE

Hello,

Super new to Linux and RaspberryPi so it took me a while to figure out how to launch the application with working UI.

To get the application working on the screen attached to the RaspberryPI I had to add two commands before launching the Java application.

My Modified SSHHandlerTarget is as follows

List<String> commands = Arrays.asList(
                    String.format("%s kill -9 $(ps -efww | grep \"%s\"| grep -v grep | tr -s \" \"| cut -d\" \" -f2)", params.isRunAsRoot() ? "sudo" : "", params.getMainclass()),
                    String.format("cd %s", path),
                    String.format("tar -xvf %s.tar", consoleView.getProject().getName()),
                    "rm *.tar",
                    "export DISPLAY=:0.0",
                    "export XAUTHORITY=~/.Xauthority",
                    cmd);

The two added lines

export DISPLAY=:0.0
export XAUTHORITY=~/.Xauthority

make sure that the UI is displayed on the screen attached to the RaspberryPI

If you run Xming on the windows machine you can also set it up to display the UI on the windows machine.

Perhaps adding the different options to the RaspberryPI configuration can be useful.

LucosidE avatar Apr 23 '17 18:04 LucosidE

Thank you @LucosidE for this solution but does this mean you would need to fork this plugin, compile it yourself with the added code, and then load it into IntelliJ? I'm not clear as to what the exact steps would be.

@asebak would it be possible to add @LucosidE 's solution as an option in the IntelliJ configuration screen?

h2software avatar Dec 09 '17 12:12 h2software

i would like to have this feature to, but have no clue on how to implement it....

Coollision avatar Dec 18 '17 14:12 Coollision

I'm also looking at deploying a Processing GUI app to the Pi. It would be great to have the option for the export DISPLAY=:0.0 command to run before the execution of the program.

However, if anyone is looking for a simple, quick and dirty hack I found that by simply adding -version; export DISPLAY=':0.0'; java as VM Options in the configuration will work to run my GUI application straight onto the pi. I put the -version in so as not to get an error about an uncomplete java command and I also can find this information useful to display.

But again the option to have this command by default would be very much welcome to resolve this problem.

MattyB95 avatar Jan 21 '18 21:01 MattyB95