UI java-Unix
I must to interface a Unix script with java application. I try with import java.io.*; ... try{ String[] com_ps= {"/bin/sh", "-c", "/bin/chmod 755 esegue", "./esegue"}; Process p = Runtime.getRuntime().exec(com_ps); }catch (IOException e0){ System.err.println(e0); System.exit(0); } } } My script (esegue) has unix comand to create a ps file and show it. Does anybody know what kind of problem is? Thank you all!
Re: about exec
Massimo Conti wrote: > > Hi | > here is how I made this : > > import java.lang.Runtime; > > public void startService(String programName) { > > try { > path = "/your/path/"; > (Runtime.getRuntime()).exec(path+programName); > } > catch (Exception e) { > System.out.println(e); > } > } > It's not so easy.!! For exemple, if you want to run "ls", you must handle the output with stream and do a loop to show the result. For my job I need to interface some comands like this: psxy -R...parameters...> prova.ps psxy is a GMT (Generic Mapping Tolls)command which creates a ps file. It doesn't work!!! I don't know what is handled from Linux and what must be implemented with java. Is there anybody who knows more about it?
multiple selection
How can I do to implement multiple file selection with jdk1.1? I try with JFileChooser class, but multiple selction works only with jdk 1.2.. Thanks. Laura
announcement
INT just announced they have released the Beta 2 version of J/View3D, a Java 3D toolkit. It's easy to use and you need little Java programming experience to use it. Basically it simplifies your ability to create sophisticated interactive data visualizations. It has a high level API and uses the model-viewer-controller paradigm. Best of all, it's free to download. Go to j-extreme.int.com to get it. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Printing
Sir, I tried to run your sample application "TestPrint" but it wouldn't print anything ... The print dialog shows up. But when I choose "Print" from the dialog, a "Print Error" dialog shows up with the message: "Could not execute print command: [Ljava.lang.String;@80cbe12" This is the first time I tried the printing feature in Java (I also tested other sample applications, but they all wouldn't work) ... The printer (HP LaserJet 4L) is from within the (local) network ... I am using RedHat Linux 4.2, JDK 1.1.3 ... I hope you can help me on this. Thank you. -- Laura Tidbits: What can you say about the Printing API in JDK 1.2?
Re: Signing Applets
Daniel W. Dulitz x108 238-3728 wrote: > > > Can I sign an applet (JAR file) without "purchasing"/needing > > a certificate (digital ID)? > > Well, you need a certificate, but you can generate the certificate > yourself and be your own Certificate Authority (and you don't have to > pay anyone). I've did it a while ago and can give you pointers; it is > indeed useful in carefully controlled circumstances. What are these pointers? > The most obvious case where it makes sense to do what you propose is > if you have an applet that will run only on your corporate Intranet, > and you want it to be able to play outside the sandbox. Yes ... I simply wish to read data from a text file, create objects out of it, and save them back to the file afterwards ... > I don't remember where I obtained signtool10LinuxELF20.tar.gz, but I > believe that was all I needed. That's what I used ... I run: signtool -G"myCert" -k"myCert" -Z"client.jar" myDirectory And so, I got my new certificate ... but when I run: signtool -l client.jar the following message appears: NOTE -- "client.jar" archive DID NOT PASS crypto verification. (reported reason: Unknown issuer) entries shown below will have their digests checked only. status path verified Client.class verified Client.java verified index.html verified items.txt NOTE -- "client.jar" archive DID NOT PASS crypto verification. The Certificate Authority (CA) for this certificate does not appear to be in your database. You should contact the organization which issued this certificate to obtain a copy of its CA Certificate. And, when I try to run my applet on (Netscape Navigator 4.05), here's what I get: # Error: The certificate issuer for this server is not recognized by Netscape. The security certificate may or may not valid. Netscape refuses to connect to this server. (-8179) # jar file: /tmp/jzip35D335A10080306 # path: /tmp/jzip35D335A10080306 # Error: loading of signatures has failed (-1) # jar file: /tmp/jzip35D335A10080306 # path: /~lala/dataEntry/file/ I've already tried a lot of things (downloaded capsapi_classes.zip and SignTool and applied the codebase principle) just to get this applet run in a browser, but to no avail ... Please, help me on this. Thank you. -- Laura
Re: Printing
John Zukowski wrote: > Does the Linux JDK support printing? If you mean it comes with the JDK, yes ... I'm using JDK 1.1.3. > The error message seems to imply that it didn't come from the source in > from the AWT book. Is this something you added, or does it come from the > Linux port? The error did not come from the source. This error dialog is part of the Print Dialog that comes up when the getPrintJob() method is called ... (I did not change anything in the source code.) ... Right there, pjob becomes null, not giving me the chance to get into the loop following it ... > I'm no longer on the Java-Linux mailing list, so I'm not sure if anyone > else answered this for you already. My problem has not been solved yet ... I hope somebody can help me ... Printing is a real necessity ... Thank you. -- Laura John Zukowski wrote: > Thanks for your message at 04:34 PM 8/12/98 -0700, Laura L. Evangelista: > >Sir, > > > >I tried to run your sample application "TestPrint" but it > >wouldn't print anything ... The print dialog shows up. But when I > >choose "Print" from the dialog, a "Print Error" dialog shows up > >with the message: > > > >"Could not execute print > >command: [Ljava.lang.String;@80cbe12" > > > >This is the first time I tried the printing feature in Java > >(I also tested other sample applications, but they all wouldn't > >work) ... The printer (HP LaserJet 4L) is from within the (local) > >network ... I am using RedHat Linux 4.2, JDK 1.1.3 ... > > > >I hope you can help me on this. > > > >Thank you. > > > >-- Laura > > > >Tidbits: > >What can you say about the Printing API in JDK 1.2? > > > > John ZukowskiFocus on Java Guide / http://java.miningco.com > [EMAIL PROTECTED] | [EMAIL PROTECTED] > Author Java AWT Reference / Borland's JBuilder No Experience Required > MageLang Institute - http://www.magelang.com > Will hack Java code / book for food
Re: Signing Applets
> I just checked over the stuff that I did, and I used Sun's javakey. Someone told me that javakey uses DSA algorithm, which Netscape (what I'm using) doesn't understand ... > Make sure you have loaded myCert into your browser as a Certificate > Authority. How? > When you run signtool -L, you should see myCert appear as one of the certificates. Yes ... there's my certificate, with an asterisk (*) ... But when I run signtool -l, I get: using certificate directory: /home/lala/.netscape Object signing certificates --- MyCert ++ Error ++ Unable to find issuer certificate --- For a list including CA's, usr "signtool -L" > If you have problems with the "native Netscape" approach, you could > make sure your applet runs in appletviewer, use javakey to sign it, After signing (using signtool), I tried appletviewer but caught exceptions: sun.security.pkcs.ParsingException: IOException, sun.applet.AppletSecurityException: checkread I look into javakey ... > Sorry I can't tell you more without web access. It's okay ... You're time and help is very much appreciated ... :-) Than'x! -- Laura
Re: Printing
> Printing with java 1.1.6 on linux works, I don't know if it works with 1.1.3. Have you tried running the code I attached to my first post? (TestPrint.java) > The error you get is thrown if java cannot execute /usr/bin/lpr or > /usr/bin/lp. Does one of these files exist on your system? lpr exists ... and I use it in printing a web page (Netscape) and even redirecting output to printer ... > Have you tried printing to a file? Yes ... and it did print to a file ... However, the text at the left and top margin were cut off ... What could be the problem (saving to Printer)? Than'x! -- Laura
Printing from browser
Java people, I have an applet that needs to print components (reports) ... It runs fine with appletviewer, but running it through a browser (Netscape 4.05), I get security errors. How can I get my applets to print from a browser? Than'x for any help. -- Laura
Printing from applet using Netscape
Java people, I'm trying to print from my applet ran in Netscape 4.05 ... My applet is in a signed jar and uses a plugin ... Running the applet and trying to print, I get the message (from the Java console): Invalidating certificate principals in [http://blah-blah-blah/,] What needs to be done before I could get to print from my applet? Than'x for all the help ... :-) -- Laura
[Fwd: AppletSecurityException in browsers]
Java People, How can I get my applet (when ran through a browser) to read/write a text file? It works well, as usual, using appletviewer. Thank you (in advance). -- Laura
Printing (the Code)
// This example is from the book _Java AWT Reference_ by John Zukowski. // Written by John Zukowski. Copyright (c) 1997 O'Reilly & Associates. // You may study, use, modify, and distribute this example for any purpose. // This example is provided WITHOUT WARRANTY either expressed or implied. import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.Properties; public class TestPrint extends Frame { TextArea textArea; Label statusInfo; Button loadButton, printButton, closeButton; Properties p = new Properties(); public TestPrint() { super ("File Loader"); add (statusInfo = new Label(), "North"); Panel p = new Panel (); p.add (loadButton = new Button ("Load")); loadButton.addActionListener( new LoadFileCommand() ); p.add (printButton = new Button ("Print")); printButton.addActionListener( new PrintCommand() ); p.add (closeButton = new Button ("Close")); closeButton.addActionListener( new CloseCommand() ); add (p, "South"); add (textArea = new TextArea (10, 40), "Center"); pack(); } public static void main (String args[]) { TestPrint f = new TestPrint(); f.show(); } // Bail Out class CloseCommand implements ActionListener { public void actionPerformed (ActionEvent e) { System.exit (0); } } // Load a file into the text area. class LoadFileCommand implements ActionListener { public void actionPerformed (ActionEvent e) { int state; String msg; FileDialog file = new FileDialog (TestPrint.this, "Load File", FileDialog.LOAD); file.setFile ("*.java"); // Set initial filename filter file.show(); // Blocks String curFile; if ((curFile = file.getFile()) != null) { String filename = file.getDirectory() + curFile; char[] data; setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); File f = new File (filename); try { FileReader fin = new FileReader (f); int filesize = (int)f.length(); data = new char[filesize]; fin.read (data, 0, filesize); } catch (FileNotFoundException exc) { String errorString = "File Not Found: " + filename; data = errorString.toCharArray (); } catch (IOException exc) { String errorString = "IOException: " + filename; data = errorString.toCharArray (); } statusInfo.setText ("Load: " + filename); textArea.setText (new String (data)); setCursor (Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } // Print a file into the text area. class PrintCommand implements ActionListener { public void actionPerformed (ActionEvent e) { PrintJob pjob = getToolkit().getPrintJob(TestPrint.this, "Cool Stuff", p); if (pjob != null) { Graphics pg = pjob.getGraphics(); if (pg != null) { String s = textArea.getText(); System.out.println(s); printLongString (pjob, pg, s); pg.dispose(); } pjob.end(); } } } // Print string to graphics via printjob // Does not deal with word wrap or tabs void printLongString (PrintJob pjob, Graphics pg, String s) { int pageNum = 1; int linesForThisPage = 0; int linesForThisJob = 0; // Note: String is immutable so won't change while printing. if (!(pg instanceof PrintGraphics)) { throw new IllegalArgumentException ("Graphics context not PrintGraphics"); } StringReader sr = new StringReader (s); LineNumberReader lnr = new LineNumberReader (sr); String nextLine; int pageHeight = pjob.getPageDimension().height; Font helv = new Font("Helvetica", Font.PLAIN, 12); //have to set the font to get any output pg.setFont (helv); FontMetrics fm = pg.getFontMetrics(helv); int fontHeight = fm.getHeight(); int fontDescent = fm.getDescent(); int curHeight = 0; try { do { nextLine = lnr.readLine(); if (nextLine != null) { if ((curHeight + fontHeight) > pageHeight) { // New Page System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum); pageNum++; linesForThisPage = 0; pg.dispose(); pg = pjob.getGraphics(); if (pg != null) { pg.setFont (helv); } curHeight = 0; } curHeight += fontHeight; if (pg != null) { pg.drawString (nextLine, 0, curHeight - fontDescent); linesForThisPage++; linesForThisJob++; } else { System.out.println ("pg null"); } } } while (nextLine != null); } catch (EOFException eof) { // Fine, ignore } catch (Throwable t) { // Anything else t.printStackTrace(); } System.out.println ("" + linesForThisPage + " lines printed for page " + page
Signing Applets
Java People, Can I sign an applet (JAR file) without "purchasing"/needing a certificate (digital ID)? -- Laura