nachoraven
Posts: 8
Joined: Sun Jul 14, 2013 2:53 pm

Runing JAVA GUI at Startup

Tue Aug 27, 2013 8:34 pm

Hi Everyone, after lots of work and research I managed to run my JAVA GUI thanks for the help you guys gave me in this post...

http://www.raspberrypi.org/phpBB3/viewt ... 81&t=51830

Now I need some help again... right now to run the GUI I have to:

1. Start the Raspberry
2. Once it finishes loading go to "startx" to go to the desktop
3. Once there go to the terminal
4. There type "java -jar jarname.jar"

With that i managed to run the application, tho it supposed to be full screen but i still see the bottom bar.

I wanted to ask you guys 2 questions:

a. Is it possible to run the JAVA GUI at startup? Just plug and see my GUI?
b. How do i get rid of the bottom bar of the desktop?

Thank you again for all your help!!!

User avatar
xranby
Posts: 540
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Runing JAVA GUI at Startup

Wed Aug 28, 2013 7:40 am

nachoraven wrote: a. Is it possible to run the JAVA GUI at startup? Just plug and see my GUI?
Try follow DaveDriesen's 3-step tutorial on how to configure a debian/raspbian system to start a single application that depend on X11 on bootup:
http://www.raspberrypi.org/phpBB3/viewt ... 08#p344408

In step 3 make sure your .xinitrc contains:
java -jar jarname.jar
nachoraven wrote: b. How do i get rid of the bottom bar of the desktop?
The 3-step tutorial will only start your application without a "window-manager" or bottom toolbar, the only way to get a bottom bar is to explicitly start it. Mouse and keyboard input will work ok without a window-manager but there is no way to move the application windows unless one is started.

If you want to move window border you also need to start a "window-manager" in parallel to your application. The .xinitrc will then look like this:
#openbox-session is the lxde window-manager
# commands ending with & will not wait until the command is exited,
# & allows the openbox-session and your application to be run in parallel
openbox-session &
java -jar jarname.jar
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

nachoraven
Posts: 8
Joined: Sun Jul 14, 2013 2:53 pm

Re: Runing JAVA GUI at Startup

Thu Aug 29, 2013 2:46 am

Thank you very much for you help xranby after a whole afternoon of learning and tweaking I took what you said, what the post you mention said and some google info and managed to:

- Load automatically no need for user and password
- Load startx at startup
- Start GUI at startup with no bar at the bottom.

Tho i have a big problem. Seems this procedure is messing up with my JAVA GUI, the GUI takes images and text information form JPG and TXT files that are in a folder. Till now this worked like charm, with this new autostart tho the GUI starts but it starts with no text or images inside.. just a empty shell... any idea what could be happening?

Thank you again for you help.

User avatar
xranby
Posts: 540
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Runing JAVA GUI at Startup

Thu Aug 29, 2013 10:39 am

nachoraven wrote:Thank you very much for you help xranby after a whole afternoon of learning and tweaking I took what you said, what the post you mention said and some google info and managed to:

- Load automatically no need for user and password
- Load startx at startup
- Start GUI at startup with no bar at the bottom.

Tho i have a big problem. Seems this procedure is messing up with my JAVA GUI, the GUI takes images and text information form JPG and TXT files that are in a folder. Till now this worked like charm, with this new autostart tho the GUI starts but it starts with no text or images inside.. just a empty shell... any idea what could be happening?

Thank you again for you help.
Check the permissions on the folder and files are readable by the system user that you use to startx and run the .xinitrc.

from a terminal cd into the folder you have the text and image files and check the permissions using:
ls -la

ls will then print lines something like
drwxr-xr-x 16 xranby xranby 4096 jul 9 13:45 .
drwxr-xr-x 344 xranby xranby 36864 aug 29 12:23 ..
drwxrwxr-x 4 xranby xranby 4096 maj 15 12:01 pictures
-rw-rw-r-- 1 xranby xranby 16667 apr 29 11:19 LICENSE.txt

the odd looking drwxr-xr-x drwxrwxr-x and -rw-rw-r-- is the file permissions for the current folder . , the parent folder .. , the subfolder pictures and the text file LICENSE.txt

The first letter in the file permission string is special and is marked "d" for direcory folder entrys and "-" for normal files.
The next three letters "rwx" indicate that the file/folder can be read "r", written to "w" and executed/entered "x" by the user who owns the file/folder.
The middle three letters "rwx" indicate that the file/folder can be read "r", written to "w" and executed/entered "x" by the group who owns the file/folder.
The last three letters "rwx" indicate that the file/folder can be read "r", written to "w" and executed/entered "x" by any other user on the system.

If the permissions are set wrong then the user who runs the startx and .xinitrc may not have "r" read permissions on the files or "rx" permission on the folders.

You can update the permissions on files and folders using the chmod command.
example
chmod o+rwx LICENSE.txt
makes all "other" users on the system able to read, write and execute the LICENSE.txt file

chmod u-rwx LICENSE.txt
removed the permissions for the owner "user" to read write and execute the file.

for further information look at the manual
man chmod
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

nachoraven
Posts: 8
Joined: Sun Jul 14, 2013 2:53 pm

Re: Runing JAVA GUI at Startup

Fri Aug 30, 2013 1:22 am

Wasn't that but found the problem... only had to put sudo before the command of running the JAVA.... so simple and I made so many things to work around... well its all part of the learning :lol:

Thank you very much xranby you are great teacher!!!

Regards!

User avatar
avatar1337
Posts: 78
Joined: Sun Jan 27, 2013 3:14 pm

Re: Runing JAVA GUI at Startup

Sun Sep 08, 2013 5:33 pm

A tip is to create an .xsession file in your home folder. In there you can start a Java application that requires X11 which gets run instead of your regular desktop. When you exit that application X11 exit as well. =)
The creator of the Raspberry Pi Configuration Manager (PiCon)

aldofado
Posts: 7
Joined: Sat Sep 14, 2013 10:41 pm

Re: Runing JAVA GUI at Startup

Sat Sep 14, 2013 10:47 pm

Excellent thread! I got everything working.
Now what is the best Java code to display an unmovable frame that occupy the whole screen with no outside borders?

Regards,
aldo

User avatar
avatar1337
Posts: 78
Joined: Sun Jan 27, 2013 3:14 pm

Re: Runing JAVA GUI at Startup

Sun Sep 15, 2013 4:14 am

When you start an application in the .xsession file (notice the dot) you don't get any borders because your window manager doesn't start. You can't move the application either. To maximize a normal X window you can use a flag, for instance --geometry 1280x1024 or --maximize I think, but look that up. With Java and Swing I think you must specify the desired resolution in code. But you can find the resolution in the Java code and then set it, or you can simply set it to be maximized in the Java code but I am not sure if that works without a window manager.
The creator of the Raspberry Pi Configuration Manager (PiCon)

muth
Posts: 27
Joined: Sun Aug 05, 2012 3:32 pm

Re: Runing JAVA GUI at Startup

Wed Sep 18, 2013 11:44 am

aldofado wrote:Excellent thread! I got everything working.
Now what is the best Java code to display an unmovable frame that occupy the whole screen with no outside borders?

Regards,
aldo
Hi, I manage to have full screen app with these lines :

Code: Select all

        JFrame f = new JFrame("Pilogger");
        f.getContentPane().add(new PiloggerImpl(simulation));
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setExtendedState(JFrame.MAXIMIZED_BOTH); 
        f.setUndecorated(true);
        f.setVisible(true);
        f.pack();
        ... etc ...
But with the window manager, I don't know the behavior just with X11.

aldofado
Posts: 7
Joined: Sat Sep 14, 2013 10:41 pm

Re: Runing JAVA GUI at Startup

Wed Sep 18, 2013 1:58 pm

Cool! Thanks. Appreciated

aldo

champsxs
Posts: 1
Joined: Sun May 24, 2015 4:57 am

Re: Runing JAVA GUI at Startup

Sun May 24, 2015 6:45 am

nachoraven wrote:Thank you very much for you help xranby after a whole afternoon of learning and tweaking I took what you said, what the post you mention said and some google info and managed to:

- Load automatically no need for user and password
- Load startx at startup
- Start GUI at startup with no bar at the bottom.

Tho i have a big problem. Seems this procedure is messing up with my JAVA GUI, the GUI takes images and text information form JPG and TXT files that are in a folder. Till now this worked like charm, with this new autostart tho the GUI starts but it starts with no text or images inside.. just a empty shell... any idea what could be happening?

Thank you again for you help.
can you please tell what exactly you did . because i did every thing in the post but my pi goes into blank black screen

User avatar
clicky
Posts: 480
Joined: Thu Oct 25, 2012 7:34 am

Re: Runing JAVA GUI at Startup

Wed May 27, 2015 7:04 am

nachoraven wrote:Thank you very much xranby you are great teacher!!!
+1 - excellent post @xranby

Return to “Java”