aspose file tools*
The moose likes Java in General and the fly likes How to run an application once Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to run an application once" Watch "How to run an application once" New topic
Author

How to run an application once

kelly devon
Ranch Hand

Joined: Apr 15, 2004
Posts: 75
Goodday,


please i need help!! i have two forms, one creates a user name and password, the other asks the user to login normally.
I have no clue on how to make the first form to launch once and for all so that when next the application is run it will only display the login form.
please help me figure this out.


thank you


kel
Hernan Tavella
Ranch Hand

Joined: Apr 28, 2012
Posts: 42
hi you should use a data base to save registers of what user have already create an account or not, so the next time the program run it will check in the date base if it exist an bring the correct form.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

When the user logs in for the first time, persist the data in a file or database. Database will be a better option. Next time when the application starts, check whether you have already persisted the data, if this is the case login normally or else show the login form.


Swastik
Viktor Pergjoka
Greenhorn

Joined: Aug 30, 2010
Posts: 20
Hi,
you could save the value in a properties file or whatever else what is persistence.
Then if the form was created you write the value. On loading you read the value and asks if the form was created or not.

In Pseudocode:
boolean wasCreated = getValue() //gets the persisted properry
if (!wasCreated)
....//your form
... wascreated = true
....

On the next call the value is true so the if statement is true and the form will not be created.
kelly devon
Ranch Hand

Joined: Apr 15, 2004
Posts: 75
Ok, let me try it. thanks for the clue. I appreciate. let me get to work!! Love you guys
Joe Areeda
Ranch Hand

Joined: Apr 15, 2011
Posts: 318
    
    2

I guess I'm a bit confused (a normal situation)

How do you know which user it is before they log in?

I suppose if this is an application that runs in a single user's account that is not shared you could do something with the login name, uid, or save some sort of config file in their home directory.

Most applications I know of, like this forum, combine the log in and register form since it is only used once to register.

Joe


It's not what your program can do, it's what your users do with the program.
Hernan Tavella
Ranch Hand

Joined: Apr 28, 2012
Posts: 42
Joe Areeda wrote:I guess I'm a bit confused (a normal situation)

How do you know which user it is before they log in?

I suppose if this is an application that runs in a single user's account that is not shared you could do something with the login name, uid, or save some sort of config file in their home directory.

Most applications I know of, like this forum, combine the log in and register form since it is only used once to register.

Joe


You can persiste the user information in a file directory, and when the program run read the file first and evaluate if the first form is going to be shown or not.
Phil English
Ranch Hand

Joined: Jun 18, 2012
Posts: 62

kelly devon wrote: Goodday,


please i need help!! i have two forms, one creates a user name and password, the other asks the user to login normally.
I have no clue on how to make the first form to launch once and for all so that when next the application is run it will only display the login form.
please help me figure this out.


thank you


What are you using for your GUI? If it is a web page then you could maybe try something with cookies.

It might also be worth taking a step back, what is wrong with having a standard landing page in your GUI with a Login/Password setup and adding an "I don't have one" button to launch your new user form?From empirical evidence of using the web this seems to be a pretty standard approach. This might be simpler than trying to recognise users and also means that you don't have to worry about recognition failing gracefully (i.e. if you fail to recognise an existing user you will need the new user form to have an option for them to log in using their original details otherwise they could end up having to create a new login each time).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run an application once