asebak / embeddedlinux-jvmdebugger-intellij

Embedded Linux JVM Debugger for Raspberry Pi for IDEA Platform
Apache License 2.0
55 stars 21 forks source link

Running a command before launch #67

Open rozling opened 8 years ago

rozling commented 8 years ago

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?

BartoszKaszewczuk commented 8 years ago

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.

asebak commented 7 years ago

@BartoszKaszewczuk thanks for answering that one.

scherpbier commented 7 years ago

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.

robbederks commented 7 years ago

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

LucosidE commented 7 years ago

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 commented 7 years ago

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.

h2software commented 6 years ago

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?

Coollision commented 6 years ago

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

MattyB95 commented 6 years ago

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.