Can the java binary edited or translated to assembly?

Hya,
I was wondering how can i modificate a java program, after it has been compiled /binary/ or is there any way to translate it to assembly /a programming language/ then modificate it and reassemble it?
Thanks

After compiling a program say A.java
You can see byte codes in assembly form
by typing javap -c A.java
This is similar to assembly program ,
JVM executes this code which in in class file

Similar Messages

  • When instructed "the java binary in your path"

    please help
    when Im instructed with the following:
    a JDK or JRE 1.0+ (see www.javasoft.com) installed and the java binary in your PATH
    my operating system is windows server 2000
    how do i set the path to to the java binary, Is the java binary. Is the java binary the bin folder, if so i have two of those, one directly under the jdk folder and one under jre folder.
    Do i use autoexecute.bat, if so how.
    thank you for any help rendered.
    Yaary

    Oh oh.
    Java uses the sys var CLASSPATH to look for - well - java classes.
    For that reason, CLASSPATH should always include ".;<yourJavaDir>\jre\lib\rt.jar" or ".;<yourJavaDir>\j2re1.4.x\lib\rt.jar". This ensures that Java can find the classes that come with the distribution (i.e. everything in rt.jar) and all classes in the directory from which you invoke Java or Javac.
    Now, the "<yourJavaDir>\jdk1.x.x\bin" thingie belongs into your PATH variable - that's the var your system uses to look for executables, i.e. java or javac.
    Regards, Thomas

  • Can the Ring Properties/Edit Items/Labels be populated by array values?

    Can the Ring Properties/Edit Items/Labels be populated by array values?
    I'm trying to troubleshoot an existing LabView 7.0 application at our office (this is only the beginning of my nightmare) and I'm finding that there is an array being created out of discrete Elements, which is then being indexed using the Indexed Array function, using a Ring control as the Index input. 
    What I'm seeing is that whoever created this "Appication" seems to require that any new 'elements' that need to be added to the array need to added in AT LEAST two locations (add the element to the array and add a label on the Edit Items tab of the Ring control used to index the array) and there may be more locations I haven't found that also needs the same information.  Since I can't see any way for the array and the ring control to 'compare' the text strings, I'm assuming the array is being indexed using the 'values' from the Edit Items tab.  Ths would allow different text in the Ring dropdown than is actually contained in the text of the array.
    This is contrary to most of the coding practices I've learned, so I'm wondering if I could use the text strings contained in the array itself to populate Item list in the Ring control?
    Later I can create an 'entry form' that would allow new parts to be added by staff that doesn't require knowledge of LabView programming. (The "Users" should NEVER have to see the underlying block diagrams/code to add or edit parts ot test parameter values.)
    Thanks

    In 8.2 you can do this with a property node and the "Strings [ ] Property".  It accepts an array of strings.  Order of strings in array sets the order in the control.  Should work in 7.0 as well.

  • Can the java bean be a JFrame

    while using the axbridge can the bean be a JFrame..i tried doing that ..but the frame is not visible while using the activex control

    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import javax.swing.tree.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    public class Abhix extends JFrame implements Serializable
    private DocumentBuilder builder;
    private DocumentBuilderFactory factory ;
    private Document doc;
    private static final int DEFAULT_WIDTH = 400;
    private static final int DEFAULT_HEIGHT = 400;
    public Abhix()
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    setTitle("DOMTreeTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    JMenu fileMenu = new JMenu("File");
    JMenuItem openItem = new JMenuItem("Open");
    openItem.addActionListener(new
    ActionListener()
    public void actionPerformed(ActionEvent event) { openFile(); }
    fileMenu.add(openItem);
    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(new
    ActionListener()
    public void actionPerformed(ActionEvent event) { System.exit(0); }
    fileMenu.add(exitItem);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    setJMenuBar(menuBar);
    Open a file and load the document.
    public void openFile()
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("."));
    chooser.setFileFilter(new
    javax.swing.filechooser.FileFilter()
    public boolean accept(File f)
    return f.isDirectory() || f.getName().toLowerCase().endsWith(".xml");
    public String getDescription() { return "XML files"; }
    int r = chooser.showOpenDialog(this);
    if (r != JFileChooser.APPROVE_OPTION) return;
    File f = chooser.getSelectedFile();
    try
    if (builder == null)
    factory = DocumentBuilderFactory.newInstance();
    builder = factory.newDocumentBuilder();
    doc = builder.parse(f);
    catch (IOException e)
    JOptionPane.showMessageDialog(this, e);
    catch (ParserConfigurationException e)
    JOptionPane.showMessageDialog(this, e);
    catch (SAXException e)
    JOptionPane.showMessageDialog(this, e);
         public String get()
              Element root = doc.getDocumentElement();
              NodeList children = root.getChildNodes();
              for (int i = 0; i < children.getLength(); i++)
                   Node child = children.item(i);
                   if (child instanceof Element)
                        Element childElement = (Element)child;
                        String text = textNode.getData().trim();
                        break;//for 1st node only
              return text;
    }

  • Need to edit a Captivate file that won't open. Can the SWF be edited?

    We are currently using Adobe eLearning Suite 2 (Cp5).
    We have 2 older Captivate files (Cp 3 or 4) that will not open; they act like they're opening but eventually they just time out without the error message that you normally get with a corrupt file.
    So all we have access to are the SWFs & zip files that were uploaded into our LMS.
    We are switching to a different LMS and need to quickly make an edit to these files before they are uploaded to the new LMS.
    Is it possible to edit the SWF (delete about 30 seconds of content off the end of each file) and still have them function as far as registering completion? And if so, what program would I need?

    Sorry, but only Adobe can speculate as to why the older files refuse to open in the newer version. Phase of the moon? Jupiter aligning with Mars while the house of the Moon is in retrograde?
    Personally, I'm going with the Mass Coronal Ejection theory!
    Assuming there is really no interaction going on, you *MIGHT* be able to fudge things to get that last 30 seconds to go away by playing the SWF and using Captivate to record the SWF as it plays.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Can the Java 3D package be used for colonscopies?

    http://www.cnn.com/2004/HEALTH/04/14/virtual.colonoscopy.ap/index.html

    Is that "colonoscopies" or "colons copies"?Well, since we're using an OO language, I'm sure we can do:
    Colon largeColon = new LargeColon();

  • Help in Java Micro Edition SDK 3.0 EA...

    Hi, I am using the Java Micro Edition SDK 3.0 EA version. I have a problem that when i write code to access the RecordStore, it does not seem to work. Plus, for the FileConnection programs, where do i store the accessible file structure on the disk. In WTK, it was under the appdb of the specified emulator, but i dont know the path from where the filesystem is mounted.
    Another problem is that, I want to create a simple Java class in a separate file in the SDK. But, when i right click and select "New" on the project, it only shows options to create MIDlets or MIDlet Canvas files..
    Any help will be highly appreciated. Thanks..:-)

    About the file structure in FileConnection, in NetBeans it is in C:\Documents and Settings\[your user name]\j2mewtk\2.5.2\appdb\root
    You can change the root folder if you go to "manage emulators", then in "tools & extensions", click on "open preferences" and then select "storage". I don't know if SDK 3.0 has it too... sorry... I switched to NetBeans because it has more options...
    About creating a separate file, I always did it manually, adding a .java file to the src directory (with notepad, for example). Again with the full NetBeans, right-clicking in the project gives you an option to create a new Java class so you don't have to do it manually.
    About the record store, I don't know, sorry... But I answered 2 of 3! :)

  • NW04 Java Slim Edition - wsnavigator, SQLTrace, uddiclient

    I have installed the Java slim edition and I try to go thru various tutorials.
    When I hit the following url's I receive the error message:
    http://gpandesk:50000/uddiclient
    http://gpandesk:50000/SQLTrace
    http://gpandesk:50000/wsnavigator or
    http://gpandesk:50000/inspection.wsil
    404   Not Found
    SAP J2EE Engine/6.40 
    The requested resource does not exist.
    Other url's [System Information, User Management
    ,Web DynPro and J2EE examples] work OK.
    Should I do some kind of setup using the Visual Administrator ? Can you give me some instructions?
    Thank you in advance

    I have the same error message if I use the URL http://localhost:50000/uddiclient or http://localhost:50000/SQLTrace. I also use the Java slim edition. Maybe this resources are not available with the Slim Java edition?

  • Can the Plug-in Compete?

    Why hasn't Java become the dominant technology in RIA development?
    I'm not the first person to ask this question, nor will I be the last. It is unbelievable to me that the company that invented the RIA over a decade ago has made little or no progress in this field and presents absolutely no challenge to inferior technologies that came later. JavaScript was named "Java" script deceptively to give it better visibility in the marketplace, but given its dominance in the RIA market, you'd never believe it.
    I have been developing software for over 25 years now with the majority of my experience in C++ development and object-oriented analysis and design. Wanting to move into the web market, I started doing RIA development a few years ago. I was horrified by the development options available to me and the seemingly infinite amount of hoops I had to jump through to get even the simplest application functionality implemented and working correctly. I had been using Java to do backend work and had really come to like it. To me, the ideal situation would be to use Java to do the client-side work as well as the server-side work. Not only would I be using a real OO programming language, I'd also be using a single technology across the board. The problem was that there really was no nice client-side Java solution available. Swing was just too cumbersome and inflexible and other products had similar drawbacks. What I really wanted was a client-side solution that was as easy to use and just as flexible as HTML/CSS for building a UI, but provided the dynamic and robust programming features of Java. So I quit my full-time job about 18 months ago and started designing a Java-based RIA product called the Galileo RIA Framework.
    One of the many frustrations that I had experienced working with JavaScript was the problem of inconsistent appearance and behavior on different browsers; therefore, when I started designing Galileo one of its primary requirements was that it be able to run on all major browsers on all major platforms and produce a consistent looking UI. Knowing the history of the Java Plug-in, I wasn't sure if it would meet this requirement. Much to my relief, it turned out that the latest Java plug-in (1.5 at the time) worked fine with all the latest and greatest browsers (IE, Firefox, Netscape, Opera, Safari, and Camino) on all of my test machines which included Windows XP and Vista, Mac OS-X, and a few Linux distros. This was great. I figured now all I had to do was focus on developing the actual UI framework and I would have the product I had been longing for and a product that the Java community would be excited about.
    I recently released Galileo as a Beta and while many developers who have looked at the product have admitted that it is an impressive product and that they'd like it to gain much success, they are reluctant to use it because it depends on the Java Plug-in. This has been a major disappointment to say the least. I knew that applets had developed a stigma over the years, but I didn't realize how pronounced the distaste for the plug-in had become. The negativity and skepticism within the Java community itself is so overwhelming that any hope for wide acceptance of the plug-in seems impossible. The funny thing is that all the developers I have talked with would like the plug-in to become widely accepted, but in order for it to become widely accepted, it would have to be used, however, most website developers are hesitant to use it, because, well, it's not widely accepted.
    I want to change this. Not only because the success of my product depends on it, but because I would like more job opportunities to be available to me as a Java programmer as the RIA market continues to grow.
    Why did the Java Plug-in fail in the first place?
    My guess is that there were several major reasons for the failure of the Java Plug-in. One, applets and the plug-in were introduced at a time when most users were limited to dial-up access to the internet. Downloading the plug-in and the applets that used it took too long for a normal user's patience. Two, a Swing UI compared to an HTML website designed by a graphics artist looked terrible. Three, platform and browser compatibility may have been an issue also, but not being involved in Java development back then, I don't know if that was an issue or not. Four, it has been said that installation of the Plug-in was not straightforward and could have been difficult for non-developers. Five, the web was still pretty new itself. The concept of the RIA didn't exist; therefore, there wasn't any pressure for websites to be anymore than straight HTML. Adding technology that complicated implementation, limited potential visitors, and looked bad, just didn't make any sense.
    Can the Java Plug-in compete now?
    I'm optimistic it can for several reasons. One, according to the latest statistics I've read, 86% of U.S. internet users now use broadband. Download times for JAR files and other resources have become negligible. Two, Sun has finally decided to rewrite the plug-in making it easier to detect, download, install, and upgrade. Also most major browsers will prompt the user in a standard way to install the plug-in if a page that requires it is loaded. Three, new operating systems / machines are coming with the Java plug-in already installed. I know both my Windows Vista machines from Dell did, my Mini-Mac from Apple did, and several distros of Linux install the plug-in when the OS is installed. Four, installing a plug-in just isn't a big deal for users anymore. According to a June 2008 survey 99% of internet enabled desktops have already installed the Flash plug-in and 85% have Java installed. Five, standard HTML websites are no longer the standard. To be competitive, websites will have to continue to evolve with RIAs being the latest evolutionary step. Where standard HTML sites with bits and pieces of JavaScript could be developed by graphic artists and other non-developer types, RIAs, because of the complicated implementations, require software developers. Where the major driving force in the web development market used to be graphics artists and non-developer types, as the RIA market grows software developers, many of which are Java developers, will become a greater driving force. This opens up more opportunities for Java. And six, with a framework like Galileo which allows easily customizable UI's that can look as good as any HTML/CSS based UI, aesthetics are no longer an issue for Java UI's.
    I was discussing this issue with Marty Hall of www.coreservlets.com this week and here's what he had to say:
    I would love it if a Java-based solution gained some traction in the RIA world. I spend a lot of time doing Ajax training, and right now, Ajax is tremendously complicated for developers. Developers have to learn xhtml, XML, JSON, JavaScript, Prototype, 37 other JavaScript libraries, and a server-side technology (servlets/JSP, PHP, ROR, or whatever). Even with integrated technologies like GWT or JSON-RPC, there are still an awfully lot of underlying technologies for a developer to master, and the interface is still limited by what current browsers can support."
    I really hope your framework catches on. It would be a good thing. You could build apps that were so much better if you had a real programming language and a single underlying technology.
    The more compelling apps out there that get people to install Java in their browsers the better. And the more powerful but simplified GUI frameworks like yours, the better.
    JavaRiaDev.org
    I believe a window of opportunity has opened to give the Java Plug-in a rare second chance. It appears that Sun believes this too, since they have taken the initiative to redesign the plug-in and to create JavaFx. However, with no disrespect to Sun, if Java developers expect the plug-in to succeed due to Sun's efforts alone, I think they are sadly mistaken. In order for the plug-in to succeed, a concerted effort by the Java community will be necessary. For this reason I have created JavaRiaDev.org. The main initiative of this effort will be to pool developer resources to create RIAs that utilize the Java plug-in and appeal to a broad audience by coming up with new ideas for websites, copying successful website ideas and making them better, and/or trying to forge strategic partnerships with existing websites that already have a substantial user base who are looking to upgrade to RIA technology. The second initiative will be to provide the appropriate resources to help other developers interested in Java RIA development. I, of course, will be pushing Galileo, but will welcome the use of any product that promotes the use of the Java plug-in.
    There will no doubt be skeptics in the Java community who say this is a fool's errand. But for those like me who are not content sitting on the sidelines waiting for others to decide their fate, I say join me and help me in my effort to make Java, if not the dominating, at least a viable option for RIA development. Personally I'd like to have an impact that creates the general opinion that any machine connected to the internet that isn't equipped with the Java plug-in is an inconvenience to the user. If a machine has a modern browser there's no reason for it not to have the plug-in.
    If you are interested in becoming a part of this effort, please email me.
    Thanks,
    M. Warble
    [email protected]

    Some people on the forum claim that you can use an iPhone charger with an iPad, but it will charge slowly enough to the point where the iPad won't show charging status.
    You can use the iPhone with either charger, but that doesn't hold true for the iPad, like Kappy says.

  • Question about Java Micro Edition

    Hello,
    I am interested about writing a program for PDAs. These seem to be running the Java Micro Edition, so I guess this is a good choice. But what about programming the GUI with the j2me? Afaik, it does not support swing, and the specifications are so full of abbreviations that I do not undertand that I really don't know other than to simply ask here about the possibilities of GUI programming with j2me, is there a "standard" gui library for j2me, or is it device-dependant, and is it possible to install the j2me under windows/linux for developing and testing purposes?
    Help please.. ;-)
    Thanks
    Jan

    thx :) J2ME seems to be very interesting. But zeb is right with the post in the discussion thread for this article, "where to start" is an important questions. So please, sun, make it easier for us to us (hobby-)programmers to adopt J2ME..
    I found this one alternatively:
    www.ewesoft.com
    does anyone have experiences with it?
    Jan

  • Java Enterprise Edition Installation Issues

    Hello
    I am trying to install version 8 of the Java Enterprise Edition software but I am experiencing 2 errors. Sometimes I get a message that it cannot find the jre and now the jvm. I have JRE_HOME and JAVA_HOME defined. When this happens after the path page is done, I get a dialog error message with just an x in it. The other error happened once after defining the variables with an out of memory error. I have 2 gigabytes of memory,
    I need some help.

    Enterprise Edition -- that's the one you pay a lot of
    $$ for, right? I would think those $$ entitle you to
    telephone support, or am I wrong?They have an enterprise trial that allows you a free 30 days (full functionality).
    I personally have not had any problems with it. (WinXP, RedHat 9.0)
    Smooth like butter.

  • Where can i see the java file of a container converted JSP file

    I am using weblogic11g.
    Where can i see the java file of a container converted JSP file .

    Hello.
    If you look for .class files, you will find them under $domain/servers/serverName/tmp/application/etc.
    If you look after .java translated files, nowhere if you don't have "keepgenerated" param set to true in the appc/jspc command line (may be set in a web descriptor but can't find a reference). The foo.java will be find in .\WEB-INF\classes\jspservlet.
    Edit: http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webapp/weblogic_xml.html
    Regards.
    Aurélien.
    Edited by: Aurelien DEHAY on 24 août 2009 17:12

  • File Access with unsigned Applet through editing the java.policy file

    I'am starting to lose my hair on this...
    I am trying to get an applet to run so that it can access the file system to move files on my local maschin. Because this applet is only running on my VM i can change the java.policy to avoid the signing of the applet.
    first of all, if i wrote in the java.policy file
    grant {
      permission java.security.AllPermission; 
    };everything is working perfekt.
    But I have not the intention to open the gates for any applet out there, so i want to limit the access to my applet. With every of the following versions I get at best an
    java.security.AccessControlException: access denied (java.io.FilePermission...
    My Setup
    My Java Version: jre1.6.0_02
    My applet is located unter the url
    http://admin.mydomain.com/applet.jar
    In Html i tryed the following different versions of loading the applet - none worked
    <applet codebase="http://admin.mydomain.com/" name="shortcut" code="start.class" archive="applet.jar" width="0" height="0"></applet>
    <applet codebase="http://admin.mydomain.com" name="shortcut" code="start.class" archive="applet.jar" width="0" height="0"></applet>
    <applet name="shortcut" code="start.class" archive="http://admin.mydomain.com/applet.jar" width="0" height="0"></applet>in java.policy i tryed following versions with every html applet load version
    grant codeBase "http://admin.x-press.de/-" {
      permission java.security.AllPermission; 
    grant codeBase "http://admin.x-press.de/+" {
      permission java.security.AllPermission; 
    grant codeBase "http://admin.x-press.de/applet.jar" {
      permission java.security.AllPermission; 
    };why is it with
    grant {
      permission java.security.AllPermission; 
    };working, and not with the other versions?
    i am almost bold now, please try to save my last hair from falling down.
    any suggestion would be nice
    thanks, feyyaz
    Message was edited by:
    feyyazdogu

    I read the mentioned documentation and your right, some of my versions were wrong, but after reading the doumentation again i came to following result which should had worked but didn't.
    java.policy
    grant codeBase "http://admin.mydomain.com/*" {
      permission java.security.AllPermission;
    HTML File
    <applet codebase="http://admin.mydomain.com/" name="shortcut" code="start.class" archive="applet.jar" height="0" width="0"></applet>if I am entering http://admin.mydomain.com/applet.jar i can download the jar, so the archive lays in the correct directory.
    what i am doing wrong? do i have to change an additional file somewhere else?

  • When will the netweaver java full edition be available.?

    Olivar,
      can u plz upload the netweaver java full edition?
      I kind of need it urgently.

    I promise it's coming - I just got the new files today. Have one open question for the developers who created it, once I have that solved, I will prepare the files as soon as humanly possible for you to download!
    - Kathy, SDN

  • Can I create a cert with the Java API only?

    I'm building a client/server app that will use SSL and client certs for authenticating the client to the server. I'd like for each user to be able to create a keypair and an associated self-signed cert that they can provide to the server through some other means, to be included in the server's trust store.
    I know how to generate a key pair with an associated self-signed cert via keytool, but I'd prefer to do it directly with the Java APIs. From looking at the Javadocs, I can see how to generate a keypair and how to generate a cert object using an encoded representation of the cert ( e.g. java.security.cert.CertificateFactory.generateCertififcate() ).
    But how can I create this encoded representation of the certificate that I need to provide to generateCertificate()? I could do it with keytool and export the cert to a file, but is there no Java API that can accomplish the same thing?
    I want to avoid having the user use keytool. Perhaps I can execute the appropriate keytool command from the java code, using Runtime.exec(), but again a pure java API approach would be better. Is there a way to do this all with Java? If not, is executing keytool via Runtime.exec() the best approach?

    There is no solution available with the JDK. It's rather deficient wrt certificate management, as java.security.cert.CertificateFactory is a factory that only deals in re-treads. That is, it doesn't really create certs. Rather it converts a DER encoded byte stream into a Java Certificate object.
    I found two ways to create a certificate from scratch. The first one is an all Java implementation of what keytool does. The second is to use Runtime.exec(), which you don't want to do.
    1. Use BouncyCastle, a free open source cryptography library that you can find here: http://www.bouncycastle.org/ There are examples in the documentation that show you how to do just about anything you want to do. I chose not to use it, because my need was satisfied with a lighter approach, and I didn't want to add a dependency unnecessarily. Also Bouncy Castle requires you to use a distinct version with each version of the JDK. So if I wanted my app to work with JDK 1.4 or later, I would have to actually create three different versions, each bundled with the version of BouncyCastle that matches the version of the target JDK.
    2. I created my cert by using Runtime.exec() to invoke the keytool program, which you say you don't want to do. This seemed like a hack to me, so I tried to avoid it; but actually I think it was the better choice for me, and I've been happy with how it works. It may have some backward compatibility issues. I tested it on Windows XP and Mac 10.4.9 with JDK 1.6. Some keytool arguments changed with JDK versions, but I think they maintained backward compatibility. I haven't checked it, and I don't know if I'm using the later or earlier version of the keytool arguments.
    Here's my code.
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.security.KeyStore;
    import java.security.KeyStoreException;
    import java.security.NoSuchAlgorithmException;
    import java.security.cert.CertificateException;
    import javax.security.auth.x500.X500Principal;
    import javax.swing.JOptionPane;
    public class CreateCertDemo {
         private static void createKey() throws IOException,
          KeyStoreException, NoSuchAlgorithmException, CertificateException{
         X500Principal principal;
         String storeName = ".keystore";
         String alias = "keyAlias";
         principal = PrincipalInfo.getInstance().getPrincipal();
         String validity = "10000";
         String[] cmd = new String[]{ "keytool", "-genKey", "-alias", alias, "-keyalg", "RSA",
            "-sigalg", "SHA256WithRSA", "-dname", principal.getName(), "-validity",
            validity, "-keypass", "keyPassword", "-keystore",
            storeName, "-storepass", "storePassword"};
         int result = doExecCommand(cmd);
         if (result != 0){
              String msg = "An error occured while trying to generate\n" +
                                  "the private key. The error code returned by\n" +
                                  "the keytool command was " + result + ".";
              JOptionPane.showMessageDialog(null, msg, "Key Generation Error", JOptionPane.WARNING_MESSAGE);
         KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
         ks.load(new FileInputStream(storeName), "storePassword".toCharArray());
            //return ks from the method if needed
    public static int doExecCommand(String[] cmd) throws IOException{
              Runtime r = Runtime.getRuntime();
              Process p = null;
              p = r.exec(cmd);
              FileOutputStream outFos = null;
              FileOutputStream errFos = null;
              File out = new File("keytool_exe.out");
              out.createNewFile();
              File err = new File("keytool_exe.err");
              err.createNewFile();
              outFos = new FileOutputStream(out);
              errFos = new FileOutputStream(err);
              StreamSink outSink = new StreamSink(p.getInputStream(),"Output", outFos );
              StreamSink errSink = new StreamSink(p.getErrorStream(),"Error", errFos );
              outSink.start();
              errSink.start();
              int exitVal = 0;;
              try {
                   exitVal = p.waitFor();
              } catch (InterruptedException e) {
                   return -100;
              System.out.println (exitVal==0 ?  "certificate created" :
                   "A problem occured during certificate creation");
              outFos.flush();
              outFos.close();
              errFos.flush();
              errFos.close();
              out.delete();
              err.delete();
              return exitVal;
         public static void main (String[] args) throws
              KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException{
              createKey();
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    //Adapted from Mike Daconta's StreamGobbler at
    //http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=4
    public class StreamSink extends Thread
        InputStream is;
        String type;
        OutputStream os;
        public StreamSink(InputStream is, String type)
            this(is, type, null);
        public StreamSink(InputStream is, String type, OutputStream redirect)
            this.is = is;
            this.type = type;
            this.os = redirect;
        public void run()
            try
                PrintWriter pw = null;
                if (os != null)
                    pw = new PrintWriter(os);
                InputStreamReader isr = new InputStreamReader(is);
                BufferedReader br = new BufferedReader(isr);
                String line=null;
                while ( (line = br.readLine()) != null)
                    if (pw != null)
                        pw.println(line);
                    System.out.println(type + ">" + line);   
                if (pw != null)
                    pw.flush();
            } catch (IOException ioe)
                ioe.printStackTrace(); 
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import javax.security.auth.x500.X500Principal;
    public class PrincipalInfo {
         private static String defInfoString = "CN=Name, O=Organization";
         //make it a singleton.
         private static class PrincipalInfoHolder{
              private static PrincipalInfo instance = new PrincipalInfo();
         public static PrincipalInfo getInstance(){
              return PrincipalInfoHolder.instance;
         private PrincipalInfo(){
         public X500Principal getPrincipal(){
              String fileName = "principal.der";
              File file = new File(fileName);
              if (file.exists()){
                   try {
                        return new X500Principal(new FileInputStream(file));
                   } catch (FileNotFoundException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        return null;
              }else{
                   return new X500Principal(defInfoString);
         public void savePrincipal(X500Principal p) throws IOException{
              FileOutputStream fos = new FileOutputStream("principal.der");
              fos.write(p.getEncoded());
              fos.close();
    }Message was edited by:
    MidnightJava
    Message was edited by:
    MidnightJava

Maybe you are looking for

  • How do I get all hyperlinks to open in a new tab instead of redirecting the open page?

    Simply put, when I hit a hyperlink I do NOT want the page I'm on to go to the linked URL -- I want the new URL to appear in a new and separate tab. FF used to do this just fine -- until I "upgraded" to 5.0.1 yesterday. Between this and the smaller sc

  • My apps are in chinese or japanese

    please help me to fix this, all apps i get from app store are in chinese!

  • Suppression of warnings - Urgent

    The system is BW 7.0 Had a small problem At the query designer level, description of a few info objects is changed as per reporting needs. On running the query in the web mode, they get a warning stating Characteristic & was changed in InfoCube &. Ad

  • "No Music" after update to ipod software 2.2

    I just updated my ipod firmware to version 2.2. I go to play my collection and now it says " No Music." But, in Itunes and on the Ipod itself it shows the mp3s must still be on the ipod's hard drive because they are taking up the hard drive space the

  • Strange error in forms Developer!!

    Hi friends I installed oracle form 9.0.4 in a system. While design a form, form developer automatically exit when I click on Lay out editor. I never face this problem before in other machines. Again , I can compile and Run forms in the same machine.