I'm relatively new to programming, I've been developing a lot lately in the eclipse environment and had the idea to build a small application for windows 7 that when I remove the power cord from my laptop it will enable my touch-pad and when the power is reconnected disable the touch-pad.
My question is how exactly do I go about building such an application?
Is there a package I can import that gives me access to the Windows 7 API?
And is it possible to compile a java application so I can have it run at startup?
I agree with Andrew that java is probably not the best choice for such kind of application but anyway here is what you can do.
Java 7 file API is able to listen to file system. You should listen for the changes is root folder of your card. I guess you will get exception when card is disconnected.
Touch pad may be invoked as an external application. Take a look on this discussion for details: Java - invoke on-screen keyboard
Alternatively you can use JNI, JNA or one of java-to-windows libraries (JaWin, Jintegra, Jinterop). But I think this is much more complicated. I'd recommend you to start from the first solution.
Related
several years I used to come on the bible of coding and I have (maybe) a question rarely asked. First of all thanks to all people which takes time to answer us.
I have a network with a Linux server and some Windows clients. On the server I have to use a Java application (I don't have source code) but it's hard to use it on the server : graphic card drivers are not update then the resolution of the screen is "small" and not expandable. It's a problem because layouts of the app are not dynamics then some important buttons are not displayed (is it so hard to use a JScrollPane ???). And I don't really want to learn how many times I have to use Tab for each hidden button.
Then one solution is to launch the app on a Windows client through MobaXterm. It works well but at one moment a process need a library.
I tried to launch the app by adding the library path of the library, a *.so file, but didn't work.
The question is : a java application installed on Linux and launched through a windows client need *.so or *.dll library ?
Thanks.
Florent
Does anyone know how I can make a java program run on a webpage? I know many browsers now days do not support Java for security risk, but say I was using an older Java version like Java 6.
What would I have to do to get it to run on a webpage? Of course saying "Allow" or "Run Program" whenever the user clicks a button is alright. I cannot use Javascript for this.
Thank you
Another option, apart from Applets, is Java Web Start:
Java Web Start software provides the power to launch full-featured
applications with a single click. Users can download and launch
applications, such as a complete spreadsheet program or an Internet
chat client, without going through lengthy installation procedures.
With Java Web Start software, users can launch a Java application by
clicking a link in a web page. The link points to a Java Network
Launch Protocol (JNLP) file, which instructs Java Web Start software
to download, cache, and run the application.
If you are planning to do something very CPU consuming is better to use Java Web Start. But if you need some JavaScript And Java interaction it would be better to use the old Applets.
If you are worried about browsers blocking or not supporting Java Applets, then Java Web Start is again a better option.
The following links may be of interest to you:
Java Web Start (Jnlp) Hello World Example
Java SE 6: Migrating Applets to Java Web Start Applications
These things are called Applets. They are considered to be a bit old technology but they are still used at some places.
You can find a tutorial here
I've actually already asked questions regarding my problem. To prevent people asking for irrelevant details over again, I'll post this background info you can skip:
I'm making a automation application. This application does some tasks
for the user over time for specific window. When these taks are
required to be made, window flashes in taskbar and sometimes even
steals focus to get the user to do the task. Once the automation is
here, this is no longer wanted - the user will only focus the window
when he wants to check how well is the automation doing it's job.
I discovered this focus and flash disable dll project thanks to this superuser post about applications stealing focus.
My automation application is in Java. So while I can open a DLL injection application and disable flashing manually, I'd like to integrate it in the java applicaton - for example as a setting option. When user selects to disable flashing and stealing focus, the dll will be injected.
Of course, this requires Java to be able to inject my .dll file. I've found this project: dotnet-dll-injector but it only deals with .NET dll files.
Q: Is there a way, in Java, to pick a .dll file and inject it into process? Which libraries would lead to this if the solution isn't straightforward?
I've noticed CreateRemoteThread is somehow related to the DLL injection. Maybe JNA library supports that?
I don't know of a way to do it natively in Java.
Since you've found a working solution in .NET and your task is Windows-specific, I suggest the following:
Build dotnet-dll-injector as a DLL and call it from your Java app. How to call into .NET dll from Java
Edit: easier to build it as a console app and use Runtime.getRuntime().exec("...");
Or if you're still early in the development process and you have no immediate plan to go cross-platform, just do everything in C# and save some headache.
I want to develop a Java application, hoping that the system never goes to hibernate when my application running.
The application will be deployed in Windows.
Is there any way to realize this?
There is nothing in java for this.
There are windows API to prevent hibernation. See this thread Prevent windows from going into sleep when my program is running?
You could all call them via JNI or JNA
There are two ways to avoid your system going into Hibernate mode when your application is running:
1) I don't know which Windows operating system you are talking about; but we can disable or enable Hibernation at an operating system level. The enabling/disabling method might differ for different Window versions.
2) Another way would be to write a C++ program that uses Win32 API to interact at system level. After writing the code, you can export it as a DLL library and then use it in the Java program. Below link provides a sample code that will help you achieve similar functionality.
http://www.codeguru.com/cpp/w-p/system/messagehandling/article.php/c6907/JavaC-PC-Standby-Detect-and-Prevent.htm
I had similar problems when i wanted to connect via RDP to my pc, i left teamviewer on, but my pc went to hibernate/sleep and this is my solution how i keep my pc "active".
Try this, go to Control Panel->Power Options:
and there u can select power plan, click on "Change plan settings" and u will get to this screen:
Hope that this will help u.
If u need some programmatic solution, try with this link:
How do you keep the machine awake?
I have been googling on this but I can't find the answer.
Can anyone tell me if you can put a Java application on the windows 8 start screen?
According to java.com
When will Java be supported in Windows 8? Windows 8 is officially
supported with the release of Java 7 Update 10. Java will only be
supported in Desktop screen. Java will not run in the Start screen.
I am not sure how to interpret this since I do not know the startscreen of Windows 8 and they talk about internet explorer 10 on the same page which makes me think they may only be talking about the browser.
Basically I want to have a tile to act like a classic windows icon. Is this the way it works and is this the way you can run a java application? Or do you need to go to the desktop interface first?
No. You can't.
All the apps on the Windows 8 start screen are the apps downloaded from the Windows Store.
All the other Java applications that you develop will run in the desktop environment, but not in the start screen.
As per this source, you can look forward towards creating apps for Windows Store using Java and then you can maybe think of putting a Java application on the Windows start screen.
You cannot put directly a Java application in the start screen in windows 8 (just as you couldn't create shortcut icons on the Desktop in Windows 7), however notice this is rarely what you want with a Windows desktop application.
Most of the times you will want to wrap your Java desktop application with a windows installer which will put the start screen icon on windows 8.
Your Java code will then be launched by the installer executable which might do some house cleaning jobs like checking what compatible version of Java is installed in the computer and if required install a newer one.