First application run in J2ME [duplicate] - java

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
J2me detecting first start of application
I'm developing a J2ME application and I want to know if it is the first time to run the application in the device to be able to show welcome message to user and else the user will be taken to the main screen directly
How to make so?

A simple solution...
When the user clicks the button to close the welcome message, write out a file to disk. When you start the application the next time, check to see if the file exists - if it does, the user has already seen the welcome screen. If the file doesn't exist, the welcome screen hasn't been shown (ie first run of the application)
Rather than asking a question like this, you should post some ideas, or some code, to show us that you've at least tried to do this yourself first.

When you first run an app, you can display the welcome message & then create any normal file like any .txt. Make your code such that # startup each time it will see if that file is present or not. If present, go to main screen n if not, show welcome message & create the file.
Edit:
Agreed with Doctoror Drive. Much richer way of storing data is with Record Store. Check this.

Related

Reflecting code inside of Android applications from hosting servers without new build

Greetings of the day
I know you have a busy schedule. Would you like to give me your 10 to 20 minutes for a discussion. I have a doubt and did some google search for this. There are some information but those are not much clear.
I am sure that if this doubt resolved and we found the solution to achieve the objective. It will help us for each and every project. It can be a time taking solution but only required once to get the line.
Doubt :- Do we can make an application which hit an url and take a response and according response performe some commands to write and read or modify the file itself.
In Java or other language.
In short without building new generated file code can reflect as like in web it happen.
Example :- we write and save the code file in web development at host location. Browser hit the url and show the output as it is newly writen code.
If we have added a new button in our website it reflects after saving the file.
Same thing I wanted to perform in Java and Android or dart.
Issue to solve:- the review time taken by play store. And for each update we need to build new apk each time.

One-time Java Configuration file on a desktop app

I am doing now a desktop app like a organizer. When the program starts, it has 0 tasks, obviously. I go adding more tasks, but when I close the program and then restart it, all the tasks I have done will be on null.
I think I can use a file that the program will consult. This file will have all the relevant information for load all the tasks.
But, and problem comes here, I want to make a question like "Where do you want to save the configuration file?" It is like Eclipse`s message at start with the workspace. The idea is that the message will only be show until the user specify a valid route.
Can we do this in Java?
Use java.util.prefs.Preferences: https://docs.oracle.com/javase/8/docs/api/java/util/prefs/package-summary.html

Is there a way to replicate an IDE's console like Eclipse, or NetBean's on a website?

I've created a website portfolio and I want to show some of the projects I've done. But so far the many of the projects I've done have been in java, or C/C++ and the interactive/fun programs take input from the console.
I was wondering if there was a way to simulate those program using JavaServer Faces and taking input from a textbox (possibly) to be used in the java program I've created and posted back to the website.
Just to give you an idea of the kinds of programs I'd like to show. They range from simple things like determining if the entered data from the user is a leap year to a text I/O credit card validation program I've made up.
If my question is clear enough, does anyone have any ideas about how I can show the programs I've created?
I thought of creating a java class that writes the output data from the java file in a String and then posts that to the webpage, but then the user would have to frequently refresh the page. So I thought if I could somehow simulate the console on the website that would take care of that problem.
Extra: Is there any easy way to display javafx programs on a website?
Thank you in advance!

Check if system/computer has a display or graphical output available [duplicate]

This question already has answers here:
How to detect if a graphical interface is supported?
(5 answers)
Closed 8 years ago.
Update: as marked duplicate, I just want to mention, this seems like a duplicate, but the answer to the other mentioned question is not completely correct. Instead refer to the accepted answer below.
isHeadless would return unexpected true in certain cases.
Its a bit weird situation, but recently I build a very simple java application which can be run in console/terminal mode or in JavaFX UI mode.
However, then while using it on a remote computer which doesn't have any display attached. I got an error that this JavaFX UI application can't be initiated on systems without display, which is pretty obvious.
To overcome this problem, I have been looking for a robust way of detecting if the system has any display attached and it can initiate a JavaFX application, which has to be a platform independent solution, since it could be Windows or Ubuntu/Linux or Mac system.
Structure of the application:
A Main console app, which depending on input arguments executes internally a console app or UI app.
So that, if any arguments given, run in console mode or if no arguments then run in UI mode.
This is where I want to detect if there is a display available from within my main console app, which then won't even try to run the UI app if display is missing.
Any idea how can we achieve this or suggestion in a proper direction would be great.
I think you could use java.awt.GraphicsEnvironment
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
which will return an array with all the available screens. If this array is empty, there is no monitor.
Edit: About using isHeadless(), you can look at How to determine if GraphicsEnvironment exists

Facebook Application To Post To A Fan Page

I am trying to make a simple Application on facebook.
There will only be one user using this, me.
Say I have 10 photos to upload everyday, I thought i'll make an application that will simply take every image in a directory and simply upload it to a page. A Fan page assume "X"
I started out by making an app in developer.facebook.com, say "X app".
Then I got the facebook4j library and tried posting a status as the page, using manage_pages permission.
I am stuck at many ends in this attempt and just wanted to ensure this is the right way to do it, or am I doing something enitrely wrong perhaps?
There is already a complete answer to this question here (even with the needed source code).
However, if you need to do this automatically, create a PHP script that will take N new photos from a directory, upload them to your Facebook fan page and moving or deleting them when they are successfully online.
Then just use crontab on your server to call this script everyday at a chosen hour.

Categories