Ending Process Of Another Running Jar File

Apr 16, 2015

I am working on a management gui for a program. I have implemented the start server button. But now I need to get something working so that when I press stop server the javaw.exe process which is running the the other jar file is stopped and ended.

The gui is going to be using a javaw.exe as well and I don't want to end the entire thing.

I just want to end the javaw.exe process that is running the other jar file.

This is my code for starting it:

JButton btnNewButton_2 = new JButton("Start Server");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Runtime rt = Runtime.getRuntime();
try {
Process pr = rt.exec("java -jar DEDServer_release.jar");

[Code] ....

I just need to figure out what to do to stop it now.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: How To Cancel A Long Running Database Background Process In Program

Apr 16, 2014

Can we cance/stop a long running database query execution instantly so that we can do any another task.

As i know swing uses a single thread i,e Event Dispatch Thread (EDT), But at the same time we can use Swingworker class for better use of UI. When we use Swingworker class the process goes to a different thread and our basic UI is not Frozen. Infact we can do another task. But what I want is I want to stop of cancel the execution of swingworker thread ( Because I that thread takes long time to execute). How can I do that??

I used ProgressMonitor and in the cancel option i canceled the task ( worker.cancel(true) also i closed the connection and statement for executing the database query using stmt.close() and conn.close() methods.

But it does not work. How to cancel a long running database background process in a Java Swing Program.

View Replies View Related

File I/O - How To Process Contents From Input File

Mar 22, 2014

So my assignment is to read these values from an input file which I previously created. The 10 values represent miles traveled and I convert them using some formula my prof gave me to get the total cost, and output both values to an output file.

My programming question is the first number on the input file isnt a mileage value its the number 10, which is the number of values to be processed, which we're supposed to use in order to control a for or while loop which we'll use to process the contents of the input file. How would I create a while or for loop and get it to skip the first value of the input file?

We're not allowed to use arrays for this assignment.

Also here's my code so far, and it says its not being able to find the file, I made sure the file name is exactly as saved, and its saved in the same directory as the java class that i created for this assignment so I don't see what the problem could be?

Here's my the class with the main method

import java.util.*;
import java.io.*;
 public class QudratullahMommandi_3_07 {
 public static void main (String[]args)

[Code] ....

This is the error message I get

----jGRASP exec: javac -g QudratullahMommandi_3_07.java

QudratullahMommandi_3_07.java:17: error: unreported exception FileNotFoundException; must be caught or declared to be thrown
Scanner input = new Scanner(inputSource);
^
1 error

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

View Replies View Related

Read And Process File Using Thread?

Nov 4, 2014

I created a main class called X and two Y and Z classes.

Y and Z implements Runnable classes.

class X contains a static array A that can be accessed in Y and Z.

The Run () method of the class Y reads an input file and populates the vector A.

The Run () method of the Z class uses data stored into the vector A to process some data.

The objective of using threads in this problem is: as the vector A is filled in the Run () method of class Y, the Run () method of the class Z will processing the received values ​​in the vector A.

to do this I did the following calls in the main method of class X:

ObjectY y = new Y ();
Thready thread = new Thread (objectY);
threadY.start ();
ObjectZ new Z = Z ();
Threadz thread = new Thread (objectZ);
threadZ.start ();

is that correct? I'm getting the expected results, but dont know if the code is parallelized in fact.

View Replies View Related

Using Interface To Process A File And Return In Different Format

Jun 15, 2014

I'm working on an assignment where the program has to process a file and read every line then print it out in all caps. I'm pretty sure I have most of it written out, however, I am having trouble with my main method. I am supposed to call my go method in my FileProcessor class and have it use the StringProcessor interface to call my Upper class. I'm using an interface because I will be adding other classes later, but for now I am having trouble with implementing it all in my Driver class.

How do I declare a StringProcessor object in my Driver class and how can I use it so that it would create the file in all caps?

Here's my code so far:

Driver.java
import java.util.Scanner;
import java.io.FileNotFoundException;
import javax.swing.JFileChooser;
import java.io.File;

[Code].....

View Replies View Related

Java Runtime Get Result Output From Prompt / Large File - Process Will Hang

Aug 13, 2014

I am using java process to start a system command in windows

Runtime r = Runtime.getRuntime();
Process pr = r.exec(cmdString);

I want to get the prompt out put from cmdString = "cmd /c type fileSmallSize"->>>> It is ok the have the content of the file when file is small.

However, for a large file java process will hang and no Exception occurred, what is the problem?

The easiest testing you can try on the logging.properties file in java.

public static String executeCmdAndReturnPromptResult(String cmdString)
throws Exception {
LOGGER.entering(CLASSNAME,
"Entering executeCmdAndReturnPromptResult()", cmdString);
String cmd = cmdString;

[Code] ....

It seemed to me that the bufferSize is limited so that I can only have it less than a default one, how to increase it?

My question now is how to increase the size of buffer in order to read a larger InputStream ?
BufferedInputStream() default size is
private static int defaultCharBufferSize = 8192;
private static int defaultExpectedLineLength = 80;

How to make it larger and working? I tried to increase the defaultCharBufferSize to 500000000 but it did not work!

View Replies View Related

Running A Test With A File?

Jun 11, 2014

I just wrote a java program with eclipse that has to read many-many inputs from the user. I want to test it, but I really don't want to type it everytime again and again...

Can I just write all inputs in a text file and let eclipse read this file so instead of typing it again and again, Eclipse reads every line whenever it waits for a user input?

View Replies View Related

Running Out Of File Descriptors

Nov 6, 2014

We've got a java web app (running on a Solaris machine with Weblogic) and from time to time it stops working due to this error:

Java Code: java.net.SocketException: Too many open files mh_sh_highlight_all('java');

For what I've read we are somehow exceeding the established limit of file descriptors, and it seems that this may be caused for many reasons, not only open files that we forgot to close.

I am making a list of everything that may consume a file descriptor in the system mentioned above, so I can start reanalyzing the app... if needed, as I don't know if we're wasting them or if the limit is just insufficient.

View Replies View Related

Error While Running In Command Prompt Only - In Eclipse Running Fine

May 19, 2014

This is my program: RemoteXMLRead.java

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.apache.commons.io.filefilter.WildcardFileFilte r;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.File;

[code]....

It is working fine when i run in Eclipse, but is giving error when i run in cmd.. What i need to do to over come this..

View Replies View Related

Running Java File From Linux CMD

Apr 24, 2014

import acm.util.* ;
import acm.program.*;
import java.awt.* ;
class Chap6_ex1 extends ConsoleProgram {
public void run() {
println("This program displays a randomly schosen card.");
int number = rgen.nextInt(1 ,13);
int suit = rgen.nextInt(1 ,4);

[Code] ....

I am running the this from a Linux command line , in the cmd first i use :

javac -classpath acm.jar Chap6_ex1.java

end then :

java -cp .:acm.jar Chap6_ex1

The output i m getting after second command is :

Exception in thread "main" acm.util.ErrorException: Cannot determine the main class.
at acm.program.Program.main(Program.java:1358)

I know the problem is from the RandomGenerator class in packet acm.util.* but i dont know how to fix the problem . Every other program has worked . What I am missing or how this whole issue of packet importing works when running a java file from cmd ?

View Replies View Related

Running Jar With Libraries From Jar File In Linux

May 22, 2014

I'm running a jar of an application and library jars from lwjgl. I'm creating a java process. It's working on Windows but not on linux.

I tried replacing the semicolons with colons but it didn't work, it just said "Main class not found: Application.natives.linux" or something like that. gamePath is the path the application is in. osName is the name of the operating system.

Here's my code:

String jarRunner = String.format("java -Djava.library.path="%snatives/" + osName + "" -cp "%sjar/lwjgl.jar;%sjar/lwjgl_util.jar;%sjar/jinput.jar;%sjar/slick.jar;%sApplication.jar" main.Main", gamePath, gamePath, gamePath, gamePath, gamePath, gamePath);
  
Process p = Runtime.getRuntime().exec(jarRunner);
 
[Code] ....

How can I make it work on linux?

View Replies View Related

Ending The Run After If A Condition Is Not Met?

May 24, 2014

For an assignment

-I am too write a program that checks if 3 numbers (scannerinputted) are three sides of a triangle if not just ignore it.

-If they are the 3 sides to a triangle tell what kinda triangle it is Right/scalene/equilateral etc.

-ignore the 3 numbers if they are <=0

if(side1+side2>side3 && side1+side3>side2 && side2+side3>side1)
System.out.println("This is a Triangle.");
else
System.out.println("Not a Triangle.");

How can I make the program stop immediately if the else statement is checked. I have more "if statements afterward.

so it would say.

"This not a triangle"

"This is scalene or isosceles"

how can I get this output.

"This is not a triangle" and stop there.

View Replies View Related

Scanning Input File Then Running Applet

Oct 14, 2014

So this is probably pretty simple but I can't seem to figure it out. My teacher wants us to write a code that scans a text file, then outputs some text based information AND displays an applet bar graph of the data sorta like this for the text:

Sample Bar Graph

1-10 |*****
11-20 |******
21-30 |**
31-40 |*
41-50 |***********
51-60 |******
61-70 |********
71-80 |***
81-90 |****
91-100 |****

and then an applet thats the same info just a little more graphic. My code interprets the input well, but when i try to make an applet output, the code basically forgets all of my variables and starts anew (when i just state the public static graphic (paint) class after everything) OR it refuses to scan the input file (if i switch the public class from main.....throw ExceptionIO to just public class graphic(paint))

Also, as a side note, any way to have java automatically determine how many separate lines there are in a text file without me having to manually count them.

import java.util.Scanner;
import javax.swing.JApplet;
import java.awt.*;
import java.io.*;
public class Project2 extends JApplet {

[Code] ....

View Replies View Related

Running C Compiled Executable File In Java

Jul 10, 2014

I'm trying to run a command line executable file using java but there is no output. On the task manager a conhost process opens when the application is run. I've tried

1)try {
Runtime.getRuntime().exec("D: est.exe");
} catch (Exception e) {
e.printStackTrace();
}

2)String[] cmd = { "D: est.exe"};
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();

and

3)//Runtime.getRuntime().exec("D: est.exe", null, new File("D:"));

same thing happens i.e. nothing happens.

View Replies View Related

Loop Ending With ESC Button?

Jun 10, 2014

end the loop with the ESC button.

import java.util.Scanner; 
class Sum {
public static void main(String[] args) {
int sum = 0;
System.out.println("Please write a number, end with ESC button");
Scanner in = new Scanner(System.in);

[Code] ....

View Replies View Related

Loop Ending With ESC Button

Jun 10, 2014

I'm doing old projects . This loop will take any number, sum it and when you press the ESC button the loop will end and you will be shown the sum.

Java Code:

import java.util.Scanner;
class Sum {
public static void main(String[] args) {
int sum = 0;
System.out.println("Please write a number, end with ESC button");
Scanner in = new Scanner(System.in);
int number = in.nextInt();

[Code] ....

Here is the error

Java Code:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

The operator != is undefined for the argument type(s) int, null mh_sh_highlight_all('java');

So well, the int ain't boolean says itself. also null ain't that for string ?

The original project was to get the number using one dialog box, convert the string to int and run the loop, so when you pressed ESC there then the return would be null.

View Replies View Related

Files Ending In Numbers

Jan 12, 2014

I have a program that uses a text file. The text file is in a folder called "map1". The text file itself is called "store1.txt". The program crashes when trying to read the text file, but has no problem with the folder. It also reads a png file called "1.png" and has no issue. When I change the name of the text file to "storeOne.txt", it works without problems. Why is this?

View Replies View Related

Ending The Input With Space

Apr 2, 2014

Here is the question I'm having trouble with:

Write a program that reads a list of characters:

eg.ubccdddwfreshawbgtiijhktrocbfgrtwghdddguppgrkitt. etc.

inputted from the keyboard one character at a time starting with a vowel (The vowels are a, e, i, o, and u) until a blank {spacebar} character is issued. You do not press enter after each character. Any other sequence should return an error message and a way of entering it correctly.

Having read in the list (or during the reading of the list) the program is to find the longest continuous occurrence of consonants, outputting the vowels between which this occurs and the length of this string of consonants.

{In the example above, the output would be 13ou}

Check for input errors and respond accordingly.

I have done most of it, the problem being that I don't know how to end the scan with a space so that I don't have to press enter. I have done the bit that finds the biggest amount of consonants in a row. (I'm writing in netbeans)

View Replies View Related

How To Detect When Program Is Ending

Feb 24, 2014

I have java program that I am debugging with NetBeans. In it I open a serial com port. It seems that if I exit the program the serial port is not closed so I cannot get the port the next time I start the program.

Is there a way I can detect that either the user clicked the "X" in the upper ight of the GUI or I clicked the "Stop Button" in NetBeans?

View Replies View Related

XML Parser - Cannot Read Files While Running Program From JAR File

Feb 27, 2014

I have a program that is a XML-parser, and it works fine when I'm running it from NetBeans. But when I create a JAR-file and run the very same program, it cannot find the xml file. Consider this small program that addresses my problem:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;

[Code] .....

View Replies View Related

Read File From LoginModule Running Under Security Manager

Nov 27, 2013

I have followed the Java tutorial on JAAS Authentication and Authorization. All the sample code in the tutorials works fine also when running under a security manager. Now I am trying to modify the LoginModule class, so that it uses a password file to look up users and passwords, but as soon as I try to run the code under a security manager, I get a Security Exception. I suppose it has something to do with the code havent been granted any access to read the password file? So I tried to add this to the policy file:

grant codebase "file:./sample/module/-" {
permission java.io.FilePermission "sample/module/passwords.txt", "read";
};

It didn't do any difference. why I get this Security Exception?

The only difference from my code to the tutorial code, is that I have added the lines:

Scanner scanner = null;
try {
scanner = new Scanner(new File("src/sample/module/passwords.txt"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}

to the login() method of the SampleLoginModule class...

View Replies View Related

How To Communicate Two Process

Aug 5, 2014

I didn't ask you to do my home work . tell me how to communicate two java program using named piped concept.

View Replies View Related

Application Build Process

Mar 15, 2014

I need a summary of the steps involve in building java application.I have my source code, already compiled but I don't know the next step to make it run on a particular device. I know of emulator but I need more information.

View Replies View Related

JAX-WS - Process ID Of Web Service Request

Aug 22, 2014

I am using JAX-WS to develop web services.
 
I would like to know how i can find the process ID associated to a request.

View Replies View Related

How To Add Shipping Address During CheckOut Process

Apr 21, 2014

I'm Fresher and i'm new in ATG nd right now working on checkout module.Here I'm trying to take shipping information of user so it is fetching in the shipping information JSP bt when i'm trying to submit that JSP den it's not going to either in SuccessURL or in ErrorURL it's remaining in current JSP.

I'm doing any customization's i'm jst using al Out Of Box Components nd my code is almost same as Out Of Box Code and it is not giving any error also.

I'm attaching my JSP's

Attached File(s)

shipping_jsp.txt (4.17K)
Number of downloads: 293
 shippingAddress_jsp.txt (1.9K)
Number of downloads: 135
 shippingSingle_jsp.txt (70bytes)
Number of downloads: 19
 shippingSingleForm_jsp.txt (2.05K)
Number of downloads: 102

View Replies View Related

Servlets :: Explicitly Process JSP From Within Container

Nov 3, 2014

I am looking for a way to have a Servlet (my container is Tomcat) calling a JSP file and processing it in order to retrieve the generated HTML. The compete scenario:

I have virtual shop and whenever a purchase is being carried out, the customer is redirected to a Servlet that post-processes the purchase (list of the items, etc.)

Among all these, the Servlet is also supposed to send me an email about the new purchase. I would like to have nice designed HTML mail and not just a simple plain text notification. I thought of having a designated JSP as a view, and it will only be available from the Servlet container, for this purpose. One way is having the Servlet create an HTTPClient (or any other method of network communication) to my own host and ask for the JSP.

I wonder if there is a simpler way to ask my own container to process a JSP, since I am not really making a request to an outside web application. Something like getServletContext.processAndReturnJsp("mail.jsp")

BTW, if you think my approach is too cumbersome to fill an email with HTML code, it would be great to know of a simpler way.

View Replies View Related







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