Solved

Any way of running a Java application within a C++ .scr Screesaver?

Posted on 2003-12-04
3
230 Views
Last Modified: 2010-04-02
Hello all,

I am about to write a screensaver in C++ (that will hopefully end up being all encapsulated in one .scr file) and my question is...

How do I incorporate a Java application into it?

As in - the screensaver will use a spider that I am writing in Java which will retrieve information that the screensaver will display. So can all this happen from within the .scr file? And if so, are there any extra requirements that the user would have to be aware of?

Thanks very much for your time,

Mark.
0
Comment
Question by:shifty_mc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 100 total points
ID: 9877653
You can alway run any Java program from a screensaver like any regular program - all you have to do is pecifying the VM on the command line, e.g.

BOOL Execute ( LPCTSTR pszCmd)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory ( &si, sizeof ( STARTUPINFO));

si.cb = sizeof ( STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;

DWORD bRes = CreateProcess ( NULL,
pszCmd
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
GetEnvironmentStrings (),
NULL,
&si,
&pi
);
return ( bRes);
}

and use it like

Execute("java -cp c:\\projects\\helloworld helloworld");
0
 

Author Comment

by:shifty_mc
ID: 9878634
ok, thanks, but you've gone over my head a bit - i'm a bit rusty at the moment and will be learning on the job i feel.

So what did you mean by on the command line? As in I take it the bottom line is the actual one to start the java program from within C++ but what about the top stuff - not entirely sure what that's doing or where it's supposed to go.

Also on a tangent - to what extent could the java program communicate with the C++? Could it (Java) tell it (C++) to stop the screensaver for instance?

Thanks a lot - appreciate it.
0
 
LVL 5

Expert Comment

by:migoEX
ID: 10364882
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept jkr's comment as answer.

Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

migoEX
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question