Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting to C# also VS2015 5 125
Handle Exceptions during instantiation 28 415
c++ syntax question 9 48
Issues with C++ Class 19 92
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
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.
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.

786 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