I have a Java game i’m creating and each window is a seperate JFrame
with its own components.
How would I get about calling variables from other .java programs?
Not quite sure how to do that.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A running JVM instance has no access to objects living in a different instance. Communication between java virtual machines has to be done with other means.
A practical way is to establish a TCP/IP based interface. One application acts as a server (opens a port) and listens to requests for data. TCP/IP based client/server solutions are not too complicated in Java.
Another rather simple alternative is using a shared file on the file system. The data provider updates this file on changes, the ‘client’ monitors this file and loads the content, whenever it detects update/change (monitor modification timestamp).
And to mention a third approach: Java Management Extensions (JMX) would help too. JConsole (part of the jdk) is a practical example on how to connect to a separate JVM and get access to (‘public’) data and methods.