knute
Posts: 462
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

.desktop file can't create terminal?

Thu Mar 22, 2018 10:43 pm

Anybody know why my .desktop file doesn't create a terminal? It runs the Java program just fine though.

[Desktop Entry]
Name=test
Type=Application
Exec=java -jar test.jar
Terminal=true
Hidden=false

Here is the test.java program if you want to try it:

Code: Select all

import java.awt.*;
import javax.swing.*;

public class test extends JFrame {
    public test() {
        super("test");
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        add(new JLabel("test",JLabel.CENTER),BorderLayout.CENTER);
        setSize(200,150);
        setVisible(true);
        setLocationRelativeTo(null);
    }

    public static void main(String... args) {
        EventQueue.invokeLater(() -> new test());
    }
}

Code: Select all

javac test.java
jar test.jar test *.class
rm *.class
The reboot!

klricks
Posts: 6549
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: .desktop file can't create terminal?

Fri Mar 23, 2018 2:18 am

Create a bash file something like this:

Code: Select all

nano /home/pi/my_bash

Code: Select all

#!/bin/bash
Your_program_here
$SHELL
Make the bash file executable or add bash before the filename below..........

Call the bash file in .desktop file

Code: Select all

Exec=/home/pi/my_bash
This worked for me. Reference: https://www.linuxquestions.org/question ... 175529714/
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Return to “Troubleshooting”