aspose file tools*
The moose likes Java in General and the fly likes Java and activeX ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java and activeX ?" Watch "Java and activeX ?" New topic
Author

Java and activeX ?

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hi,

Has anyone created an activeX to be used from your java application ?

If so, how did you do that ?
please provide some help.

Thanks
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Do you mean activeX in a JSP web page? I couldn't imagine a reason to try and run activeX in a Java application.

Of course I can't imagine wanting to put activeX into a web page either.
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
The reason is I want to access my windows OS [systray] thru my JSP. When i login to my app, an icon should get displayed on the systray and I heard an activeX control can insert an icon on systray.

So now, have anyone created or used ActiveX from Java/Jsp ?

Thanks
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Urgent: I need some solutions here, if any one can help..
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

If you can find such an ActiveX control, then all you have to do is embed it in the HTML of the JSP page. This has nothing at all to do with Java -- the appropriate tags to embed this on the page can be in the static part of the JSP, and there's no interaction between the ActiveX control and the Java code in the JSP at all.

Now, the problem you face is that you need to find (or write) this ActiveX control, and learn how to embed it in HTML. You're not going to find the answers to these questions at JavaRanch -- you're going to have to go to a Microsoft site someplace.

Finally, in the future, can you please refrain from posting the same question in so many different threads, in so many different forums at the Ranch? I'm sure people have given you some of this information before, but none of the posters have been able to build on anything anyone else has said, because you keep starting new threads!


[Jess in Action][AskingGoodQuestions]
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
If you can find such an ActiveX control, : yes there are ActiveX controls available, but not written in Java.

Finally, in the future, can you please refrain from posting the same question in so many different threads, in so many different forums at the Ranch? I'm sure people have given you some of this information before, but none of the posters have been able to build on anything anyone else has said, because you keep starting new threads!

Regarding this: I HAVENT asked anything about ActiveX anywhere. I posted the question in Ranch, but didnt get a response. Now by going to so many places[other forums] I found out that an activeX can be used. But I am not familiar with how to integrate ActiveX with JSP. Thats why I opened a new thread[hope to get some replies], Moving threads here and there happens, but if u look, no significant help has been received. I dont know why it is like this ?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Shreya Menon:
yes there are ActiveX controls available, but not written in Java.


Of course, that's the whole point. Java can't put things in the Windows system tray, any more than a cow can drive a BMW.

But I am not familiar with how to integrate ActiveX with JSP.


You don't, and you can't, but it doesn't matter. Slap that control on your web page, and you're done. Now you just have to find the control.
David M Fairchild
Greenhorn

Joined: Apr 08, 2005
Posts: 18
This may not help much but you might be able to use JNI the Java Native Interface to do this.

In a nutshell, the JNI can call library functions in a dll. I've done this with a stand alone application but not from a web page. Java security in an applet may prevent you from using JNI.

If you are able to use JNI, you need to write your own dll, probably in C or C++ and will need to call the windows library call Shell_NotifyIcon. Here are the required definitions, but if you are familiar with windows programming in C you won't have any problem with the tray icon.

Private Const NIF_ICON = &H2
Private Const NIF_MESSAGE = &H1
Private Const NIF_TIP = &H4
Private Const NIM_ADD = &H0
Private Const NIM_DELETE = &H2
Private Const NIM_MODIFY = &H1

Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type

Private Declare Function Shell_NotifyIcon Lib "shell32.dll" _
Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, _
lpData As NOTIFYICONDATA) As Long

I've never put an icon in a tray from C, but I have from VB and it's easy enough.

All in all, it's not a quicky solution.
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Thank you David for your suggestion. will take a look at it,...

BTW, Ernest
I was reading this article:
http://www-128.ibm.com/developerworks/library/os-activex/

Again it talks about integrating an application.. But since its a nice article thought of sharing in the ranch
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by David M Fairchild:
This may not help much but you might be able to use JNI the Java Native Interface to do this.


Shreya has been advised already about JNI being an option, but rejected it because it would require installation on the client machine. The nice thing about the ActiveX version is that it can be downloaded as part of the web app.

The article you link to, Shreya, is about integrating ActiveX controls into desktop applications, where the Java code is running on the desktop machine. You're talking about a Web application, a JSP application, in which the Java code runs entirely on the server, on a different machine altogether. There's no comparison.

Shreya, can you explicitly spell out your requirements for us? Tell us exactly what you can and can't do, here. Does it have to be zero-install? Does it have to be JSP? What else?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Of course, that's the whole point. Java can't put things in the Windows system tray, any more than a cow can drive a BMW.


I have an issue with any analogy that refers to Java as a cow, while at the same time, refers to Windows as a BMW ...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Ernest,

The article you link to, Shreya, is about integrating ActiveX controls into desktop applications, where the Java code is running on the desktop machine.
Correct: I just forwarded, in case if helps

Shreya, can you explicitly spell out your requirements for us? Tell us exactly what you can and can't do, here. Does it have to be zero-install? Does it have to be JSP? What else?

Thanks for asking, first time some one asked what I want, apprecaired:

Requirements:
Insert an icon to the systray when users log in to the web application using a URL.

Yes, If possible our clients dont want anything to be installed on the client machines. Right now our app is client/server based. We install client on all client machines . When clients log in to the client, an icon gets displayed on systray.

Because of the whole world moving towards web, clients are asking whether we can convert our app to web based.[ have all code installed on a server] so that clients can go to a URL and access the app. But they want the same icon to get displayed when they succesfully login to the app.

Purpose of this icon: This icon flashes right now, when a new work comes to the users. Even if the window which they are accessing is minimised, by seeing the icon they can understand that a new work is waiting for them.
Now when the users log out of the system/close browser, this icon should disappear from systray.


Thanks and hopefully I will get some help..
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Henry Wong:


I have an issue with any analogy that refers to Java as a cow, while at the same time, refers to Windows as a BMW ...

Henry


Actually, I usually get myself into trouble by contrasting "Windows machines" on one hand with "actual computers" on the other.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Shreya Menon:

Purpose of this icon: This icon flashes right now, when a new work comes to the users. Even if the window which they are accessing is minimised, by seeing the icon they can understand that a new work is waiting for them.
Now when the users log out of the system/close browser, this icon should disappear from systray.


OK. Now, there is only one way that this could possibly function: one way or another, that icon has to be attached to a client program running on the user's desktop. That client is going to have to communicate with the server to receive information about new work units.

This client could be (among other things!):

1) A signed applet plus a native-code DLL. The user would have to download and install that DLL. They would have to have the Java Plugin installed.

2) A JavaWebStart application with a native-code DLL. The DLL could actually be included in the Java Web Start application and installed automatically. But the user would have to have Java Web Start installed.

3) An ActiveX control. This would be downloaded automatically, with zero install for the user. The downside, of course, is that this is not written in Java.

Now, regardless of what the client is, it has to talk to the web application somehow to find out about available work. Again, there are many possibilities:

1) It could simply poll a special URL within the web app. This is the simplest and works with all three client architectures. The downside is that the icon wouldn't know immediately when it was supposed to disappear.

2) It could use RMI. This would only work with 1) and 2) and can be complicated to set up, but could be bidirectional -- no polling.

3) It could use a socket connection. This would work with all architectures, and be bidirectional but is perhaps the most fragile, and could have firewall problems.

No matter how you slice it, this is a hell of a lot of work. You need to do a cost-benefit analysis before you decide to proceed.
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Ernest,



This client could be (among other things!):

1) A signed applet plus a native-code DLL. The user would have to download and install that DLL. They would have to have the Java Plugin installed.

2) A JavaWebStart application with a native-code DLL. The DLL could actually be included in the Java Web Start application and installed automatically. But the user would have to have Java Web Start installed.

3) An ActiveX control. This would be downloaded automatically, with zero install for the user. The downside, of course, is that this is not written in Java.


REgarding the client, the client can be a jsp with either an applet or an activeX [if possible] embedded in it, right ?

Thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

The Java code in a JSP runs on the server, and it runs before the user ever sees the page. By the time the user sees the web page, the Java code has run and returned. Therefore the Java code in a JSP page with an applet or ActiveX control embedded in it can not communicate with that applet or JSP. They are separated in both time and space.

The point is that yes, the client can be an applet or ActiveX control, as I said, but whether the applet or control is embedded in a JSP page or a static HTML page doesn't matter at all.

Do you understand the point I'm trying to make? It's important, and I think several people have already given up trying to get you to understand it.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

One point that I would mention on top of everything else, is that you said that when the browser closes you want the icon to disappear from the systray. Now that will be a big trick since it is basically impossible to know when the user closes the browser.

Maybe you should look into using Swing and Java Web Start so that you don't have to go to each client and install the application. And you can use Sockets to connect to the Server and have nice flashies.

Even in Visual Basic, we create a way that you wouldn't have to re-install it on the client when an upgrade occurs, it would update itself automatically.

OK, I think I stirred the Wasp's nest enough.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

But Mark, you make good points. I think a point of focus is the gab between a webapp and a desktop app. It sounds like the clients want the best of both worlds. That's fine, but they are going to be seperate.


GenRocket - Experts at Building Test Data
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hi all,

Is something gping wrong with javaranch ? I remember there were 23 replies in my post, now I can see only 17. whatever posted on friday has vanished!!! what happened ? Has any one noticed this !!!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

See this explanation.
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hoo, Luckily I saved couple of last suggestions to my PC..

well, I am experimenting with JWS. I have a DLL with me which creates an icon on my systray. Now I am going to put my DLL thru JWS to another computer. Thats where I am ..

Thanks
Erik Larson
Greenhorn

Joined: Apr 25, 2005
Posts: 10
There is a new Tray Icon API project that I saw on java.net. Check it out!

Tray Icon API

There is a JWS demo, and it works just fine on my Win2k machine. This may not help you now, but in the future it might be an option.


SCJP<br />SCJD - someday!
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Ernest,

Before trying JWS with DLL, I thought of trying JDIC tray.jar with JWS. I created a jnlp file and trying to invoke that jnlp thru a link. Now, does JWS always need to launch an application. I donot want to launch this app. I just want to install my jar file/DLL using JWS. Looks like JWS inserts jar to its own cache and automatically launches the app [That means, I need to have an application-desc tag with a main-class in jnlp file.

Have you or anyone tried to use JWS and just install jar/DLL ?

Thanks
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Shreya Menon:
Ernest,

Before trying JWS with DLL, I thought of trying JDIC tray.jar with JWS. I created a jnlp file and trying to invoke that jnlp thru a link. Now, does JWS always need to launch an application. I donot want to launch this app. I just want to install my jar file/DLL using JWS. Looks like JWS inserts jar to its own cache and automatically launches the app [That means, I need to have an application-desc tag with a main-class in jnlp file.

Have you or anyone tried to use JWS and just install jar/DLL ?

Thanks


That's not what it is for. JWS is for running java applications but launching them via the web. After the application runs the first time, any future attemp to run the application just checks for updates. If there are not, it runs. If there are updates, it downloads the new updates and then runs.

Do some reading Shreya. The JWS is full of docuemntation. You should know from reading that what JWS is used for. It's not just an installer. If you want to just install some JAR files and DLL's then use InstallShield or something designed for that.
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Just wanted to let everyone know that I am succesful in displaying my icon through a web app.

I created a DLL and called the functions implemented using JNI in my web app.

Thanks Ernest and Greg

Shreya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java and activeX ?