Communication Between Two Separate Java Program In Same Computer

Sep 20, 2012

I have two separate java Program that run on the same
computer : Program -1 & Program-2 .

Explain Program-1 :

Name of Program -1 is “InputFrame” that is a simple frame that contain a JTextField and a Button and a JTextArea .

Explain Program 2 : Name of Program-2 is “OutputFrame” that is a simple frame that contain a simple JTextArea that this JTextArea is a Instance object from a class with name of “DisplayFrame” .

This instance object from class of “DisplayFrame” added to frame of “OutputFrame”.Now I want run both Program 1 & 2 simultaneously in the same computer and when I enter a text in JTextField in Program-1 and after click on the Button “OK” that Text Entered in this JTextField In addition to JTextArea in Program-1 display In JTextArea in Program-2 .

I do not want use a share file between two Program-1 and -2 Or DataBase .I want if Program-1 run but Program-2 is not running and i enter a text in JTextFeild in Program-1 , after running Program-2 that Entered Text Displaye in JTextArea in Frame of Program-2 .(Offline Message) .Both Source code of Program-1 and Program-2 is Attached .

View Replies


ADVERTISEMENT

Servlets :: Java Standalone Program To JSP Communication

Aug 4, 2014

The following programs exist:

1. I have a java application which accepts bio potential data every second or two and stores it in the database. This is a socket server which accepts this data from multiple clients and spawns a new thread for processing it to store in the db.

2. I have a jsp page on tomcat server which reads historic client data from database (stored by application 1) and displays it on the page.

The socket server program in 1.) above is not running inside of tomcat server.The new requirement now is : Display all of the human data coming in live on the jsp page.Now the problem: I will now need to pass the live data from socket server (which is stand alone) to the jsp which is running on a tomcat server.

Possible solutions:

APPROACH 1: Run the socket server in the tomcat instead of stand alone and store the frequently incoming data in a java object so the jsp can access this object every second and display it on a graph.

PROBLEM : The stand alone java application does not need to be included in a tomcat server except for the fact that the jsp needs access to the live data. Also, I have read that this is not the best way.

APPROACH 2: Expose the stand alone java application as a web service and communicate with the jsp using REST architecture.

PROBLEM : The complication of using this method is that it will not have the flexibility offered by websockets or server sent events (SSE) of auto updating the latest data. The jsp will have to keep polling for new data every one second which is also not a very good option.

View Replies View Related

Can Use Java Code From OpenScript Or APIs In Separate Java Program?

Oct 24, 2014

I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
 
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
 
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;

[Code] ....

View Replies View Related

How To Write A Computer Based Testing Program Using Files

Jan 8, 2015

I'm supposed to write a computer based testing program using files. I have started writing however, I am stuck. I am to prompt the user to enter the file name 'test.dat" and if something different is entered then a error message should be displayed. Also the file will create an input stream for the data using the file. I am to have the user enter other information about an employee and then write the record to the file.

The program should be created so when the user enters "quit" the loop is terminated and the file is closed. I'm not asking for code. I was just giving a brief synopsis of the project. Where I am stuck is I wrote the first part of the program that creates the file; however when I enter a wrong file name the exception error message does not display. The code is below:

import java.io.*;
import java.lang.*;
import java.util.*;
public class Project5Write
{
private Formatter x;
public void openFile(){

[Code]...

View Replies View Related

Java Applications Communication On Different Systems

Nov 1, 2014

I'm new to java and haven't develop any application before that... I need to develop an application through which i can send data from 1 computer to another computer. These communication in between the computers are those are under one router connection. Means they can connect even without internet access

Main concept is as follow

1. Java application on computer A [server side application]
2. Java application on Computer B [Client side application]
3. Java application on computer C [Client side application]

Now computer B and C communicate with computer A. but they don't know about presence of each other

View Replies View Related

Swing/AWT/SWT :: Communication Between JFrame And Java Class?

Apr 19, 2014

I have a jFrame and a Java Class. Now i have a path of image in my jFrame which I want to display in java class(Crop2). I created an object in jFrame

Crop2 d=new Crop2();

and then I'm trying to send the data to the class file but it is not working.

View Replies View Related

Java Servlet :: Two Servlets Communication With Post Method

Feb 22, 2013

We have two servlets application running on same server with Java EE 6 with below mention application URL.

Servlet1 Application URL: http://<severname>/*servlet1*
Servlet2 Application URL: http://<severname>/*servlet2*

My question is how to call Servlet2 from Servlet1 with Post method without using server name. May be something like this:

servlet.invoke(servlet2).

View Replies View Related

How Java Graphics Interact With The Computer

Mar 30, 2014

I know there are Java graphics classes, and how to use them to draw images in a window, but how do those classes interact with the screen to create the image? At the very base of it all, what is the code that is passing the computer the data to display on its screen? I'm asking because I've seen several ways to do Graphics/GUIS, a lot of them involve the Graphics class, but what is it inside all of that that that makes it work? Also, is everything else involving graphics (any other graphics libraries people write) pretty much "on top" of the Graphics class or is there something else within it more basic that is being used?

View Replies View Related

Java Communication With Hardware - Show Output In Numbers And Letters

May 29, 2014

I want to make project about java communication with hardware (wiz110sr) via LAN (Rj45). And for example, my hardware have ip address 198.168.0.1 ; port: 1202, connected with my PC(via lan/Rj45). I want show the output (such as numbers and letters) from my hardware in console netbeans.

When I running my code, appear :

" Exception in thread "Thread-0" java.lang.RuntimeException: Uncompilable source code
at mypkg.startListenForTCP$1.run(startListenForTCP.ja va:48)
at java.lang.Thread.run(Thread.java:745)
BUILD SUCCESSFUL (total time: 1 second) "

Here's the code :

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import sun.rmi.runtime.Log;
 
[Code] .....

View Replies View Related

Pogo Games - Java Is Not Detected On Computer

Jun 6, 2013

I am unable to open Pogo Poker with out receiving an error message saying "Oops, Java is not detected on your computer" (or something similar). I have reinstalled it several times and get the same results.

View Replies View Related

Java Socket - Client-server Communication Stuck With Multi-threading

Feb 6, 2015

Firstly, my code is just a demo of my multiplayer game (2 or more players can play simultaneously) to demonstrate my problem without any extra things. I have successfully implemented peer-to-peer (P2P) communication in my game. Later, I decided to add support for client-server communication (ie a central server which is also a player) in my game. It should be much easier than P2P. Now here is the problem:

Suppose, I have 1 server and some clients (may be 1 or more clients). They all should give the following output:

Starting...
A
B
C
E
F
...
...
Done!

They all give the above output without using multi-thread. But using multi-threading, it gives the above output only when there're 1 server and 1 client. I'm using 2 threads (1 for sending, 1 for receiving) for each Socket. That means, each client has only 2 threads for communication but the server has (2 * totalClients) threads.

I've attached my full test project. So, here I'm only showing my 2 thread classes.

ReceiveThread class:
class ReceiveThread extends Thread {
private ObjectInputStream receiveStream;
private BlockingQueue<Character> queue = new ArrayBlockingQueue<Character>(Common.totalClients);

[Code] ....

Since I've attached my full test project, I'm not showing the other 3 classes. They are ServerMain, ClientMain and Common. If I've 2 clients to be connected, then I get the following output:

Server: (Runs first)

Starting...
A
Client 1 (clientID is 1): (Runs after the server)

Starting...
A
B
B
Client 2 (clientID is 2): (Runs after Client 1)

Starting...
A

They are stuck at there, even no exception. Actually, the server and the clients are stuck at the line try { ch = queue.take(); } if more than 1 client are connected. It seems that all are trying to receive data. But without using the dedicated threads, they all work as expected even for more than 1 client. Why is this behaviour? How to solve it? Note that I have used the same SendThread and ReceiveThread classes by which I have succcessfully implemented P2P communication.

About my attached test project file:

It has 5 small .java files for the classes as stated above. It is currently faulty when using additional threads. You have to change clientID variable for each client (they are described inside). But it works as expected without additional threads. To test it without the additional threads:

Comment " TODO" linesUncomment the single lines just after " TODO" linesComment the additional thread construction lines (4 lines)

Currently, for a workaround, I'm not using the dedicated threads for sending and receiving data only for client-server communication in my multi-player game. But I'm still using these threads for P2P communication. I don't know why it is and how to solve it.This is the attached test project file as described above.

Attached File(s) : Test Project.zip (4.11K)

View Replies View Related

Swing/AWT/SWT :: Procedure For Detecting A Unique Hardware ID Of Any Computer Using Java

Apr 8, 2014

I need to know the procedure for detecting a Unique Hardware ID of any computer using Java. All I want to do is once the software application is installed should not get installed using the same key...In short I want to do license for my application.

View Replies View Related

Number Guessing Program - Computer Guesses A Number That User Is Thinking Of Within Certain Range

Mar 28, 2015

I have a beginning Java Program I have been working on that creates a number guessing program where the computer guesses a number that the user is thinking of within a certain range. I so far have the program below, but need getting rid of a few kinks/ adding features.

-First, I need to set it up so that the user will be prompted and give a range. It should run and produce something like this:

Welcome to this first-ever mind-guessing program!

Please pick a range (higher than 1 and no larger than 50): 32

You will choose a number between 1 and 32... and I will try to guess it.

With each of my guess, you will tell me whether I am too high (h or H), too low (l or L), match (m or M), or you want to quit (q or Q). My objective is to find the number using as few guesses as possible.

-Second, the game is supposed to give up and restart after failing the five, guesses, but for some reason, after it fails the fifth time, it prompts a fifth guess once again instead, then restarts after- I need to prevent this, so that it should look something like this:

My fourth guess is 17: h
My guess is too high?

My fifth guess is 16: h
*** I am unlucky this round. I give up.

Let's play!

My first guess is 10:
etc..

import java.util.*;
import java.lang.Math;
public class numguessprac1 {
// Declaring variables
public static String input;
public static int quit;
public static int guess;
public static int wins;

[Code] ....

View Replies View Related

Adding Data File Into Two Separate 2D Arrays In Java

Apr 27, 2014

I am having some trouble with a Java program. I have a txt data file, which I will display, that I need to add into two separate arrays. The text file is 8 lines long that is supposed to go into two separate 4x4 matrices. A little background info on this program, reads in two arrays, compares them and outputs the largest elements of the same index and outputs them in a separate array. I somehow cannot seem to figure out how to do this. My code is below:

Data File:

2 7 6 4
6 1 2 4
9 7 2 6
8 3 2 1
4 1 3 7
6 2 3 8
7 2 2 4
4 2 3 1

Code:

public class prog465a {
public static void main(String[] args) {
Scanner inFile = null;
try {
inFile = new Scanner(new File("prog465a.dat.txt"));

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Java GUI With Separate Class For JList - Adding Items To The List?

Sep 19, 2014

I am trying to create a GUI interface in swing which consists of four classes: a GUI class, which creates a main JPanel, a label, and a JList, which it takes from the second class, a MovesList class that contains a JList and the stuff needed to interface with it. It also has a main class, which basically just creates an object of the GUI class for the main window, and an Other class from which I would like to be able to add an item to the JList. I created methods in the MovesList class to get each component (like getMoveslist, or getMovesListScrollPane), which I then used to create the JList in the GUI class. I also created an addMove method so that I can add an item to the JList from any class through a MovesList object. However, this addMove method only works when called from the GUI or MovesList classes -- it does nothing when I collect from the Other class.

Here is my code:

//Main class
public class TestProject {
public static void main(String[] args) {
GUI mainWindow = new GUI();
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

[Code] ....

When I run this code, I get a window with a JLabel that says "Moves," and a JList that contains five elements -- test 1-test 5, but not a sixth "test from other class." ( using the add move method ) However, when I click on the window, the addMove method is also called, and successfully adds "test 6" to the list.

View Replies View Related

Network Communication Using Sockets?

Dec 6, 2014

I have all of my code written, but it is not producing any output and i'm not sure why.

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;

[code]...

View Replies View Related

Swing/AWT/SWT :: Communication Between JFrames

May 23, 2014

I'm writing a small program in Java to simulate a shopping cart. A shopping cart has an array og objects Item. As a console application, my program runs.But, in the GUI version, I have some issues. In class MainMenu I create a ShoppingCart object, named "cart"(line 103)In class AddItemMenu I create an Item object, and I want to add it in my ShoppingCart object "cart".BUT, AddItemMenu cannot "see" variable "cart".

//MainMenu.java
package shoppingcartgui;
public class MainMenu extends javax.swing.JFrame {
public MainMenu() {
initComponents();

[code]....

View Replies View Related

Servlets :: Communication Sessions Between Two Applications?

Jul 22, 2014

I'm deployed application A and application B in TOMCAT server applications, the U1 user enters into the application A, he authenticates and generates a call to a page of the app B. As I was able to access the session of user U1 en A from B, it could have a single session.

View Replies View Related

Current Options For Applet To Servlet Communication

Feb 12, 2014

My primary question is about which method is the best for having an applet of mine communication with a backend database of mine. In other words, I don't want to try learning a technology that is out of date or not a good fit for my goal. I purchased the O'Reilly title "Java Servlet Programming", but it seems to be very old and out of date (referencing Netscape 4, etc.) and I see a Java RMI O'Reilly title on Amazon, but it was written in 2001.

My basic goal is to allow my applet to have access to a back-end database for reading and writing. I understand that direct Applet to DB (via JDBC) access is a bad idea so my thought is to create a servlet (much like web service for lack of a better term) or an actual web service (RESTful would be my first guess) to broker the requests. I already have a very basic servlet running that has access to my database server so now I want to focus on the best method for making calls from the applet to the servlet but having said that I don't want to go down this road too far if a servlet is not the right tool for the job.

My reading has been leading me to RMI, but as I said, I don't want to focus on that if there is a better option. In a non-Java environment, I'd use a web service (REST, SOAP, etc.) and perhaps that's what I should do here as well and not even bother with a servlet per se and just go with a web service.I know there can be some subjectivity with regard to these choices and I don't need to know what the "best" one is.I don't want to use RMI if it's dead or has been surpassed by something else, for example.

Should I use a servlet? Should I use a web service? My needs are rather modest; query the database, send updates to the database, etc. Nothing too crazy.

View Replies View Related

Get Computer CPU Usage?

Apr 7, 2014

I want to get current Computer CPU usage of my computer and display it in Console View of Eclipse? How can I achieve this?

My template code is:

Java Code: public class GetCPUUsage{
public static void main(String[] args){
System.out.println("CPU USAGE IS: ??????");
}
} mh_sh_highlight_all('java');

I added ??? as placeholder for CPU usage because I do not know how to retrieve RAM usage by Java.

View Replies View Related

How To Get The Actual Computer IP Address

Jan 31, 2014

I wrote a Chess game that uses socket to connect to another computer, and allow player vs player and player vs computer game sessions.

However, there is a problem which I noticed.

When you get the IP address of the computer in which the program is running, you are not getting the computer's actual IP, you are getting the Router's IP.

Is there a way to get around this.

So the problem is that when I go to another computer, located in a different house or lets say from my school, the program cannot connect back to my home IP, because it uses the router's ip, not the computer's ip I am running the server program.

Is there a way to get the Computer's IP, not the router's ip when summoning or invoking the get IP address method from the socket class?

When I say that the socket class is acquiring the router's ip, well that's done without my interfering...I don't know why it does that, it is somehow recognizing the router and not the computer.

The thing is that the server program is written that any client program is able to connect to the home server.

But when I run the program from a different location other than the current home, the sockets don't connect because it is somehow recognizing the router's ip not the computer's ip.

View Replies View Related

Display What The Computer Chose (GUI Boxes)

Nov 29, 2014

for my class we have to make a rock paper scissors game using GUI boxes. Everything is working fine I'm just having trouble displaying what the computer chose. In other words, after the user selects Rock, paper or scissors, the scoreboard just pops up displaying the score. Here's the last working program before I started tinkering with it.

// your code goes here
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;

[Code].....

View Replies View Related

Computer Wins Every Time At Connect 4 Game

May 9, 2015

I have to make my connect 4 game smarter with an algorithm that can beat the human every time. How to do it??

View Replies View Related

JRE :: Keep Temporary Files On My Computer Via Command Line On Windows

May 18, 2015

I need to activate the setting 'Keep temporary files on my computer' (Java control panel/general/settings) on about 150 Windows 7 PCs in a Samba3-Environment (which does not have GPOs). We are running Java Version 8 Update 45 (build 1.8.0_45-b14) on all of the PCs. Is there a way to change this setting with the command line, a registry entry or somehow else?

View Replies View Related

Get Current RAM Usage Of Computer And Display It In Console View Of Eclipse?

Apr 7, 2014

I want to get current RAM usage of my computer and display it in Console View of Eclipse? How can I achieve this?

View Replies View Related

Comparing Inputted Guess To Computer Random Sequence - Counter Not Working?

May 27, 2014

I have separated characters into an array that can be accessed from any method, however, when I try to compare the inputed guess to the computers random sequence, the counter always comes back as 0 (the comparison occurs in the checkColour method).

Java Code:

package mastermind;
import java.util.Scanner;
/**
* Program Description: play a game of mastermind versus the computer
*/
public class Mastermind {
private static int block1, block2, block3;
private static String blockColour1, blockColour2, blockColour3;

[Code] ....

The counter is called colourCorrect.. But I think the problem lies more in me converting the strings (input and computerGuess) into char arrays, as if I output the values at position in the array, I get numbers (but the numbers are not character values from the ascii table).

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved