Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running a command before launch #67

Open
rozling opened this issue Oct 8, 2016 · 9 comments
Open

Running a command before launch #67

rozling opened this issue Oct 8, 2016 · 9 comments
Labels

Comments

@rozling
Copy link

rozling commented Oct 8, 2016

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
Copy link

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
Copy link
Owner

asebak commented Nov 29, 2016

@BartoszKaszewczuk thanks for answering that one.

@scherpbier
Copy link

scherpbier commented Feb 18, 2017

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
Copy link

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

@LucosidE
Copy link

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
Copy link

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
Copy link

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
Copy link

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

@MattyB95
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants