|
|
The OP is asking how to make the java code respond to a query from the process.
waitFor() isn't going to help with that.
|
|
|
|
|
ahmadiss wrote: (p.getInputStream()))
That gets what the normal application 'output'.
Now you need to send it 'input'.
So you use getOutputStream()
Also keep in mind that your solution will only work if the application outputs a very, very little amount of text. If it outputs large amounts then you will need to use threads for the IO and perhaps use waitFor().
|
|
|
|
|
how to convert a java file into a stand alone file
|
|
|
|
|
Your question is not clear, a Java file is already stand alone. Please try and explain what problem you are trying to solve.
|
|
|
|
|
I suspect OP means a standalone exe.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Me too; I'm just trying to get him/her to think about what they are asking.
|
|
|
|
|
As Richard said, please reword your question. Are you trying to make a java .class file be a standalone executable?
Creating an Executable jar File[^] might be of interest to you
""Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hello
I want to create a program that signs and verifing file with jarsigner
I succed to create .jar but the keystore not
here is my code :
public static void main(String[] args)
{
try
{
String[] dd = { "cmd.exe", "/C", "dir C:\\ >keytool-genkey-alias-keystore signLegal examplestanstore.jks" };
Process p = Runtime.getRuntime().exec(dd);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
}catch(Exception e)
{
e.printStackTrace();
}
}
in netbeens it write me BUILD SUCCESSFUL (total time: 1 second) but don't create the fiel of keystores
my goal is to create that with program
do you have any idea
thank you in advance
|
|
|
|
|
ahmadiss wrote: in netbeens it write me BUILD SUCCESSFUL
So you have built your program, but you still need to run it in the JVM.
|
|
|
|
|
first thank you for your reply
how to execute it in the jvm ?
I can't run it only with program !!
|
|
|
|
|
|
Well, my French is not very good but it looks like the message says "keytool-genkey-alias-keystore is not recognised as a command or program file name". I suggest you check where this program resides and use the full pathname to run it.
|
|
|
|
|
thank you , I resolved the problem : problem in path
|
|
|
|
|
this is my code. what wrong with my code? i want to save the image on the canvas as a png picture.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.colorchooser.*;
import javax.swing.event.*;
import java.awt.geom.Line2D;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.imageio.ImageIO;
public class PaintIt extends JFrame implements ActionListener{
public BufferedImage image = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB);
JPanel buttonPanel = new JPanel();
Point lastPos = null;
Point startPos = null;
Point finishPos = null;
Graphics g;
JButton save = new JButton("Save");
JButton cancel = new JButton("Cancel");
JButton clear = new JButton("Clear");
JButton proceed = new JButton("Proceed");
JPanel canvas = new JPanel();
int changer = 1;
String path="";
public PaintIt () {
setLocation(100,100);
setSize(600,500);
setTitle("ENCODE SECTION");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
canvas.setBackground(Color.WHITE);
clear.addActionListener(this);
clear.setActionCommand("clear");
save.addActionListener(this);
save.setActionCommand("Save");
cancel.addActionListener(this);
cancel.setActionCommand("Cancel");
proceed.addActionListener(this);
proceed.setActionCommand("Proceed");
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPanel.add(Box.createHorizontalGlue());
buttonPanel.add(save);
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPanel.add(clear);
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPanel.add(cancel);
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPanel.add(proceed);
getContentPane().add(canvas, BorderLayout.CENTER);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
setVisible(true);
g = canvas.getGraphics();
g.setColor(Color.BLACK);
canvas.addMouseMotionListener(new MouseMotionListener () {
public void mouseDragged (MouseEvent m) {
Point p = m.getPoint() ;
if (changer==1){
g.drawLine(lastPos.x, lastPos.y, p.x, p.y) ;
}
lastPos = p ;
}
public void mouseMoved (MouseEvent m) {}
});
canvas.addMouseListener(new MouseListener () {
public void mouseClicked(MouseEvent e) {startPos = e.getPoint();}
public void mousePressed(MouseEvent e) {lastPos = e.getPoint();}
public void mouseReleased(MouseEvent e) {
lastPos = null;
finishPos = e.getPoint();
startPos = null;}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
});
}
public void actionPerformed(ActionEvent e) {
if("clear".equals(e.getActionCommand())) {
repaint();
}
if("Save".equals(e.getActionCommand())) {
new captureCanvasImage();
}
if("Cancel".equals(e.getActionCommand())) {
dispose();
}
if("Proceed".equals(e.getActionCommand())) {
new encode1Pane();
}
}
class captureCanvasImage {
public void capture(){
Graphics g = image.createGraphics();
canvas.paint(g);
int w = canvas.getWidth();
int h = canvas.getHeight();
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
g.dispose();
try
{
ImageIO.write(image, "jpg", new File("panel.jpg"));
}
catch(IOException ioe)
{
System.out.println("Panel write help: " + ioe.getMessage());
}
}}
public static void main (String [] args) {
PaintIt p = new PaintIt();
p.setVisible(true);
}
}
|
|
|
|
|
Are you invoking the capture method in your captureCanvasImage class?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
capture method? sorry i'm new to java. can you help me?
|
|
|
|
|
The capture method is in your inner class called captureCanvasImage. Just having a
new captureCanvasImage() inside your event listener won't do.
I did the following and it works:
captureCanvasImage myCanvas = new captureCanvasImage();
myCanvas.capture();
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
oh, thanks. but it save blank black image. I want the drawing. how?
|
|
|
|
|
It is saving as a "blank" canvas in black because inside your capture method, you are creating a new Graphics object, and not using the one that you have in your main class that has the drawing...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
how should i do to save the image?
|
|
|
|
|
From what I've read on other forums and looking around the 'net, it sounds like you might want to draw to a BufferedImage with the mouse button clicks/hold downs, and take the BufferedImage and draw it to the canvas.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
nope. i want to draw on the canvas using mouse listener, then i want to save what i have draw into a folder.
|
|
|
|
|
Yes, I understand that is what you are trying to do. I looked around on other forums with people trying the same idea you are working on, and it seems there is a funky dance between the ImageIO methods, Graphics object, and canvas. I'm checking it out with Netbeans, and I'll let you know what I come up with. Your problem with the program has me interested in figuring it out
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
okay, please help me.
|
|
|
|