I've designed a program to run off flash drives. My idea was to put an Eject button on the program so you can easily 'safely remove' the drive. However on Mac, you can't unmount the drive whilst the application is still running unless you do a force unmount. My question is, should I be doing this?
Isn't a force unmount similar to just pulling the drive out? Is it safe to make this option easily available?
Also is there any alternative?
I take it your application is running from the disk itself, yes?
Rather than force-eject the drive, you should spawn a separate process. Basically you write a little helper program that waits for your main program to quit, then ejects the disk, and finally quits itself. When you spawn the helper process, you will have to do so "without waiting." The terminology may be different depending on the language you're using ("in a new thread" or "detaching a process") but the basic idea is that you must launch a helper program to take over from your main program in such a way that your main program can quit.
It's bad form to force eject - you can't be sure the drive is not in use. On a Mac, for example, you have Spotlight reading/writing to external disks at all sorts of times.
Related
Right, my title probably made no sense. However I'll explain it now.
I have a program coded in C++ that I wish to allow a keycombo to be pressed to run the program. My program does not run all the time it only runs when clicked then closes when the operation is complete. It simply does it's function then closes itself. Now here is the question.
Would it be simpler to attempt to edit my C++ program to run all the time via a thread in a class that then called the other class to run that did the function then stopped and listened for keypress again.
Or
Create a Java program that runs all the time and listens for a keyEvent and upon doing so runs the other programs exe. Then bundle the exe and jar in to one exe that is installed and run so they have access to each other.
If I did it this way is it even possible as far as I know key events need to have focus to be able to be detected. Meaning that I would need to be running the program as my main window to detect it? Or is that not true.
I'd looked at the java route as my Java is better than my C++. Is this do-able and if so what approach would be the better one?
Hope this is explained well enough let me know otherwise.
I'm trying to find a developer to write a desktop program that has a pretty basic function. It will notify users, via some dialog (or alert) that some program is about to access the web cam. It could be skype or facetime, or whatever it is, the program should be aware of when the OS's camera is going to be accessed and notify the user. Yes, even if the user is initiating the camera themselves via Skype, the notification would still appear.
My question is this. If I need this program written in Java, is it possible? Obviously I am trying to get it done in Java so it would run on Windows and Mac.
If it is not possible, then it seems as though I'd have to write 2 separate programs on Windows and Mac.
I've come here to get suggestions so that I can connect with the right developers. If you have any suggestions, I'd be happy to hear them. Thanks!
No, you can't write this in Java. Whatever approach you take will be very system-specific (and will probably require enhanced privileges). You could write a JNI library and a Java interface, but it'd probably be about the same amount of trouble to write programs to the native UI libraries.
I created a small application that, when run, creates or updates some tables in a database by extracting data from some PDF files. Everything works fine in this desktop application, but the next step for me would be to make it possible for an administrator on a website to upload a PDF file and my Java program would then run and update the tables accordingly.
The problem is I have no idea where to start with this (the site isn't done yet, but I'm running some tests and it is going to be coded in PHP). I'd like to know what kind of technologies I need to let the server run the program and update everything as it would in the offline version. Sometimes it takes a while to update everything, so ideally, the user uploading the PDF could continue browsing other pages while the server does its job. (I'll probably implement something that when the server is done processing the file, it says if the program ended successfully or not in a log file)
Can someone tell me what terms to search for on Google or give me some pointers? I haven't chosen where my website is going to be hosted either, so if someone could tell me what to look for to know if they support running applications like this, I'd really appreciate it as well!
This could also apply to other programming languages as I know a bit of Python and C++ as well, so in the future I might have some applications in those languages I'll want to use on the web.
If I'm not approaching this the right way, I'm open to other suggestions, but the best solution would be to keep my Java program intact as I know it works exactly like I want it to and I'd rather not have to start it all over again.
If your host is *NIX based you can use crontab (Automatic Task Scheduler) to run your program at set intervals. Make it check if a "new" PDF exists, and run the program if there is. There may be a way to use Windows Task Scheduler type programs to do it on Windows. This is probably the easiest way.
Alternately you can use You can use shell_exec() in your php to execute a command on your *NIX system directly to run your java program.
Whenever i want to connect to internet,i double click a connection icon(i created it earlier where username and password(for broadband) are stored) and click connect.The icon is in the network places(Windows XP)
May i know how to launch this connection from java or any other language? (I am asking this because my Internet Service Provider doesn't charge anything between 2 AM and 8AM :-) )
Creating a system task to run the program. You shouldn't need Java to execute a program on windows.
To use Scheduled Tasks in XP: http://support.microsoft.com/kb/308569
This is going to be unnecessarily difficult with Java, I believe. You'd have to write some native code to do the job for you, at which point you may as well write your whole program in C# or C++ anyway.
But, since you asked for a Java approach, you might want to look at the Robot class. It lets you move the mouse to a specific location on the screen, click, and otherwise automate the manual actions that you are doing. It's a very fragile solution.
Alternatively, if you can figure out what command the network connection shortcut is invoking, you can directly invoke it from Java using Runtime.exec.
(I don't really see why Java is good for this task, though.)
I'm looking for a way to know in a Java application (without JNI - it's a multi-platform application) can detect if the screen is locked.
For information... our application records time while a user is working - we want it to automatically stop recording when the screen is locked instead of the user having to do so explicitly.
I don't think there is an API for that or even a way to do it all. Parsing screenshots generated by java.awt.Robot is neither platform- nor version- or even configuration-independant, and in general, I don't think "screen is locked" is a well-enough defined concept to be used in this sense - on Linux, there can be more than just one "screen" (X server), you can switch to console terminals, you can have applications running one (or more) machines display their GUIs on another machine over the network...
I confirm there seems to be no Java API to detect a screen lock status.
Spark developer gave it a try in 2006 (like this thread shows), but without giving out any details on the specific of the implementation.
However, it is likely it involved JNI and native call to functions like WTSQuerySessionInformation (To detect if disconnected use WTSQuerySessionInformation(NULL, WTS_CURRENT_SESSION, WTSConnectState) and look for WTSDisconnected).
So, as Michael pointed out, there is no "multi-platform" universal answer (to the best of my knowledge).