Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class forName creative fix help

Status
Not open for further replies.

mluken

Programmer
Dec 31, 2003
54
US
I am currently developing in VAJ which unfortunately uses the jdk1.2.1 JVM. However, I need to use the java.awt.Robot class which wasn't implemented until j2sdk1.4.1 I believe. When run on the actual server, I am using j2sdk1.4.2 so I am fine there, but I need to be able to compile the code in VAJ so I can't reference the Robot class directly. I tried creating an interface class and compiling it through a DOS prompt, however it isn't recognizing it for some reason when I run the servlet. So my next thought was try to use the forName method of the Class object. I know this doesn't work, but is there something similar to this I can try?

Class c = Class.forName("java.awt.Robot");
c.keyPress(someInt); // where keyPress is a method of Robot

Something like this would get past my issues with compiling in VAJ and at the same time would execute the java.awt.Robot class on the server since it uses the correct JVM. However keyPress is obviously not a method in the object Class, but I am hoping I am at least getting close?

Any ideas would be greaetly appreciated!

Thanks!
 
Nevermind! As soon as I sent this I thought of another solution! I am good now!
 
From previous experience, I would strongly advise against using classes available in (say) 1.4 that were not available in (say) 1.2. Especially when using AWT.

This is because when using AWT, Java is basically just a wrapper for OS dependent calls and OS dependent dll/C libraries (called using JNI) under the surface. So if you use 1.4 classes, you'll most likely be dependant on C libraries which are non-existent in your 1.2 JVM. With a deep knowledge of the all the C libraries that AWT uses, and a lot of luck, (and hoping that confliction of libraries will not occur) and of the interdependancies that the lower level JVM uses for interfacing with the OS, then this may not be a problem, but it is extremely dangerous.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top