Xserver and Java on boot/startup

aledi

New Member
Joined
Jul 30, 2021
Messages
3
Reaction score
0
Credits
32
Hello, I am creating a custom graphic interface with Java (Swing) and trying to start it on boot.

Machine: Raspberry Pi 4
OS: Raspbian OS Lite

Xserver has been installed, as well the Java environment.

All run smooth when, after the user login (automatic), I type the following commands:
> startx
after X server start
> java mygui.java

No issues.

If I add the commands inside the .bashrc file, to run on boot (after boot), the java gui start anyway, but I get some errors:

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server
xinit giving up
xinit unable to connect to X server: Connection refused
xinit server error
Couldn't get a file descriptor referring to console


I do not understand.
Is the java program that try to run before the xserver is loaded?

I am beginner with linux.
 


I don't have any recent experience with Raspian, but I think you should be able to add it to the startup applications of your desktop environment.
 
Yes, I believe the main issue is that I am starting X11 in the wrong/non optimal way, using the .bashrc file.
I guess there's some way to setup before any user login, as standard environment.
 
So you are not using a display manager? Have you tried using .xinitrc to start your desktop environment and then to use .bashrc to startx and your application. As I mentioned before after X starts you should be able to also use the startup applications in your desktop environment to have an application automatically started.
 
I am not using a display manager.
Yes, I tried to start X11 with .xinitrc and the application with .bashrc, but not luck.

Now:
- the startx command is inside .bash_profile
- java myApp.java command is inside .bashrc
and the desktop environment start, as well the java app

Seems a bit wired to my eyes, surely isn't the best way.

I would like to try this way https://www.raspberrypi.org/forums/viewtopic.php?t=42888 to.
 

Members online

No members online now.

Latest posts

Top