Solved

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

Posted on 2003-12-04
3
223 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now