Java API to read the Encrypted Values from Windows Registry settings

Is there any Java API to read the Encrypted Values from Windows Registry settings ?
My Java Application invokes a 3rd party Tool that writes the key/value to windows registry settings under : “HKLM\Software\<3rdparty>\dataValue”.
This entry is in BINARY and encrypted with 3DES, using crypto API from Microsoft.
3rd party software to encrypt the data stored in registry it
either uses C++ code: and uses the call “CryptProtectData” and “CryptUnProtectData” or
If it is a .NET (C#) it uses the call “Protect” or “UnProtect” from class “ProtectData” of WinCrypt.h from the library “Crypt32.lib.
Note: The data is encrypted using auto-generated machinekey and there is no public key shared to decrypt the Encrypted data.
Since the data is encrypted using auto-generated machinekey the same can be decrypted from a .Net / C++ application using CryptUnprotectData or UnProtect() API of WinCrypt.h from the library “Crypt32.lib.
To know more about Auto-Generated MachineKey in Windows refer the links below
http://aspnetresources.com/tools/machineKey
http://msdn.microsoft.com/en-us/library/ms998288.aspx
I need to find a way in Java to find the equivalent API to decrypt (CryptUnprotectData) and Microsoft will automatically use the correct key.
But i couldn't find any informato related to Java APIs to enrypt or decrypt data using auto-generated machinekey.
Is there a way to read the encrypted data from Windows regsitry settings that is encrypted using the Auto-Generated Machine Key ?
Kindly let me know if Java provides any such API or mechanism for this.

If the symmetric key is "auto-generated" and is not being stored anywhere on the machine, it implies that the key is being regenerated based on known values on the machine. This is the same principle in generating 3DES keys using PBE (password-based-encryption). I would review the documentation on the C# side, figure out the algorithm or "seed" values being used by the algorithm, and then attempt to use the JCE to derive the 3DES key using PBE; you will need to provide the known values as parameters to the PBE key-generation function in JCE. Once derived, it can be used to decrypt the ciphertext from the Regiistry in exactly the same way as the CAPI/CNG framework.
An alternate way for Java to use this key, is to write a JNI library that will call the native Windows code to do the decryption; then the Java program does not need to know details about the key.
That said, there is a risk that if your code can derive the key based on known seeds, then so can an attacker. I don't know what your applicatiion is doing, but if this is anything related to compliance for some data-security regulation like PCI-DSS, then you will fail the audit (for being unable to prove you have adequate controls on the symmetric key) if a knowledgable QSA probes this design.
Arshad Noor
StrongAuth, Inc.

Similar Messages

  • ECC5 How to read the stored value from Team Viewer

    Hi,
    How can I pick up the stored value from the team viewer from within ECC5?
    I would normally use FM 'HR_ASR_WDA_GET_EMPLOYEE'  to read mem id MSS01 but this doesn't exist in ECC5.
    All help appreciated.
    Rob

    Hi,
    How can I pick up the stored value from the team viewer from within ECC5?
    I would normally use FM 'HR_ASR_WDA_GET_EMPLOYEE'  to read mem id MSS01 but this doesn't exist in ECC5.
    All help appreciated.
    Rob

  • How to read the field value from Table Control

    Hello Experts,
    I am creating my first Table Control Screen. Basically I have to create a screen (102) with a table control which has 2 fields: A_QTY, B_QTY and 2 Buttons: SAVE, EXIT.
    When Clicked on 'SAVE' the data (MATNR) from a previous screen (101)  and the data (A_QTY, B_QTY) from the new screen (102) should be saved into a Z-table.
    Internal table t_data has 3 fields.
    MATNR
    A_QTY
    B_QTY.
    Table Control TC_RACK was declared like this:
    controls tc_rack type tableview using screen 0102.
    I/0 Fields:
    A_QTY type ZQTY.
    B_QTY type ZQTY.
    The screen Flow Logic:
    process before output.
    module status_0102.
      loop at t_data into w_data with control tc_rack.
      endloop.
    process after input.
      module exit_0102 at exit-command.
      loop at tc_rack.
      endloop.
    module user_command_0102.
    module status_0102output.
      set pf-status 'STATUS_102'.
      set titlebar 'TITLE_102'.
      describe table t_rack lines tc_rack-lines.
    endmodule.                 "status_0102 output
    process after input.
    module user_command_0615 input.
    case ok_code.
       when 'SAVE_RK'.
       when others.
    endcase.
    endmodule.                 "user_command_0102 input
    Now for eg, when the users enter values for A_QTY and B_QTY like this:
    A_QTY     B_QTY
    1000         2000
    3000         4000
    How can I read these values and pass them to T_DATA so that I can save it into Z-table?
    I greatly appreciate your help.
    I've gone through some previously posted threads and could not understand because my knowledge in this area is preliminary.
    Thanks a lot.
    Could you please let me know
    Edited by: dev a on Jan 13, 2010 2:46 PM

    Hi dev a
    You should use
      DATA: lv_name(30) TYPE c.
      FIELD-SYMBOLS: <QTY> type ZQTY.
    GET CURSOR FIELD lv_name.   "Get the field name in table control
    check sy-subrc = 0.
    assign  (lv_name) to <QTY>.  "Here you get the value in <QTY>
    check sy-subrc = 0.
    Also use <your table control>-current_line to get the table index uo're currently on.
    Hint: Do not use GET CURSOR LINE if you want to get table index since this gives you the line relative to dialog screen
    Good luck
    Dean Q.
    Edited by: Dean Q on Jan 13, 2010 11:11 PM

  • How to read the Key value from the Message using the text value.. Urgent

    I need to read the Key valuefrom the message pool using the text value for the Key.. Is it possible.. Please help me with sample code..
    Thanks and Regards
    Avijit

    Avijit,
    I got your requirement. I really dont know the scenario your working on but its possible to do it. There is no direct way to do so, but complexity is in getting to know the Keys dynamically from interface.
    Here you go..
         try
              Class msgClass      = IMessageTestWDApps.class;
    //Replace IMessageTestWDApps with IMessage<Your WD Component name>
              Field keys[]      = msgClass.getFields();
              IWDTextAccessor textAccessor = wdComponentAPI.getTextAccessor();
              if(keys != null)
                   String key = "";
                   for(int index=0;index<keys.length;index++)
                        key = keys[index].getName();
                        wdComponentAPI.getMessageManager().reportSuccess("Key= "+key);
                        if(textAccessor.getText(key).equals("My message text"))
                             //your logic.
         catch(Exception cnfe)
              wdComponentAPI.getMessageManager().reportException("Exe "+cnfe.getMessage(),false);
    Regards
    Abhilash
    Message was edited by:
            Abhilash Gampa

  • How to read the default value for a Registry Key

    I am trying to use webutil 1.0.2 Client_win_api_environment.read_registry to read the client registry key HKEY_CLASSES_ROOT\.xls, but the function is raising no_data_found. I can read the registry key in Regedit. I am logged on as myself as a non-admin NT user.
    P.S: The Client_win_api_environment.read_registry can actually read HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\FORMS90_PATH because FORMS90_PATH is a registry ENTRY, whereas .xls in HKEY_CLASSES_ROOT\.xls is a KEY, but I still need the DEFAULT value of the key and it does NOT seem to work with client_win_api_environment.read_registry
    My platform: Windows NT 4, Developer 9i 9.0.2.12.2, Oracle database 9.2.0.4.0, Oracle 9iDS
    Webutil.log
    ===========
    192.168.0.99:Lewis: 2003-Dec-17 16:36:44.998 WUL[getProperty()] Getting property WUL_ADD_PARAMETER
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.08 WUL[getProperty()] Value of WUL_ADD_PARAMETER=3
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.08 WUL[setProperty()] Setting property WUL_PARAM_PROPERTIES to B|14|33|50|0|2000
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.28 WUL[getProperty()] Getting property WUL_ADD_PARAMETER
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.28 WUL[getProperty()] Value of WUL_ADD_PARAMETER=4
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.38 WUL[setProperty()] Setting property WUL_PARAM_PROPERTIES to B|14|33|50|0|0
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.48 WUL[getProperty()] Getting property WUL_ADD_PARAMETER
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.48 WUL[getProperty()] Value of WUL_ADD_PARAMETER=5
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.58 WUL[setProperty()] Setting property WUL_INVOKE_SPEC to 1|14|33
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.68 WUL[getProperty()] Getting property WUL_INVOKE
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.68 WUL[getProperty()] Value of WUL_INVOKE=-1
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.78 WUL[setProperty()] Setting property WUL_PARAM_PROPERTIES to F|14|3
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.88 WUL[getProperty()] Getting property WUL_PARAM_VALUE
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.88 WUL[getProperty()] Value of WUL_PARAM_VALUE=
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.98 WUL[setProperty()] Setting property WUL_DESTROY_PARAMLIST to 14
    192.168.0.99:Lewis: 2003-Dec-17 16:36:45.98 WUL[VBeanCommon.eraseFromObjectCache()] Removed cache reference to Object 14
    Lewis Choo Man
    CMIC,
    Canada.

    Hi Manohar,
    You have to give Distribution Key "1" in the Plannner Profile as well as if you take a column for Distribution Key seperately in  your Planning Layout for Cost Element Planning, in the Excel file, you can give Distribution Key as "1" in the respective column. When you upload the data through Excel, the system will take the DKey as "1" only.
    I hope it will solve your problem. Pls revert back for further assistance..
    Srikanth Munnaluri

  • Remote Object - not able to get the returned value from java method

         Hi ,
    I am developing one sample flex aplication that connects to the java code and displays the returned value from the
    java method in flex client. Here I am able to invoke the java method but not able to collect the returned value.
    lastResult is giving null .  I am able to see the sysout messages in server console.
    I am using flex 3.2 and blazeds server  and java 1.5
    Here is the code what I have written.
    <?xml version="1.0" encoding="utf-8"?><mx:WindowedApplication  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#FFFFFF" initialize="initApp()">
     <mx:Script><![CDATA[
    import mx.controls.Alert; 
    import mx.binding.utils.ChangeWatcher; 
    import mx.rpc.events.ResultEvent; 
    import mx.messaging.*; 
    import mx.messaging.channels.* 
    public function initApp():void { 
         var cs:ChannelSet = new ChannelSet(); 
         var customChannel:Channel = new AMFChannel("my-amf", "http://localhost:8400/blazeds/messagebroker/amf");     cs.addChannel(customChannel);
         remoteObj.channelSet = cs;
    public function writeToConsole():void {      remoteObj.writeToConsole(
    "hello from Flash client");
          var returnedVal:String = remoteObj.setName().lastResult;     Alert.show(returnedVal);
    //[Bindable] 
    // private var returnedVal:String; 
    ]]>
    </mx:Script>
    <mx:RemoteObject id="remoteObj" destination="sro" /> 
    <mx:Form width="437" height="281">
     <mx:FormItem>  
    </mx:FormItem>  
    <mx:Button label="Write To Server Console" click="writeToConsole()"/>
     </mx:Form>
     </mx:WindowedApplication>
    Java code
    public  
         public SimpleRemoteObject(){  
              super();     }
      class SimpleRemoteObject { 
         public void writeToConsole(String msg) {          System.out.println("SimpleRemoteObject.write: " + msg);     }
         public String setName(){          System.
    out.println("Name changed in Java"); 
              return "Name changed in Java";
    And I have configured destination in  remote-config.xml
    <destination id="sro">
       <properties>    
        <source>SimpleRemoteObject</source>
        <scope>application</scope>
       </properties>
      </destination>
    Please help me .

    You are not able to get the returned value because if you see the Remote object help you will realise you have to use result="resultfn()" and fault = "faultfn()"
    In this you define what you wish to do.
    More importantly in the remote object you need to define which method you wish to call using the method class like this
    <mx:RemoteObject id="remoteObj" destination="sro" result="r1" fault="f1"  >
         <Method name="javaMethodName" result="r2" fault="f2"/>
    <mx:RemoteObject>
    r2 is the function where you get the result back from java and can use it to send the alert.

  • Reading the output values after each step executes in LabVIEW User Interface

    Hello all,
    Development environment: TestStand 2010 SP1 and LabVIEW 2010 SP1
    Problem: is there a way to execute the subsequent steps programatically and get the output values from each of them?
    I have already extended a little bit a Full OI interface for TestStand to load up any sequence, choose some of the steps and run them step by step (something like option to Run Selected steps). What I am trying to do is to add some actions between each step and do that in User Interface (I can't modify the sequence!), so I am starting the NewExecution with some previously configured InteractiveArgsParam and set an option breakAtFirstStep to True. Afterwards I am just doing something like Step Over when debugging the sequence and this works good, but I didn't fine a way yet to read the output values from the steps...
    Then, if I wait until the execution finishes I can read my Results by processing the ResultObject, but this works only after finalizing of the test sequence. Since I wanted to stop after each step, read the values, do some actions and continue to the next step I tried to register an event callback for Trace of Execution View Manager. I can see that after each executed step this event is triggered, but when I try to read a ResultObject returned in Event Data it is not filled with values (ResultList seems to be empty?). Is it a proper behaviour or maybe I am doing the readout in wrong way? (It is the same VI as for reading ResultObjects after sequence finishes and there it works fine for arrays, containers and other data types).
    Like I mentioned I can't modify the Test sequences, I can't add a UImessages.
    What are my options? Should the trace event returns all output values from each steps or is it just used for status checking? Or maybe there is completely different approach to that matter?
    Thanks in advance for any suggestions,
    Best Regards.
    CLA, CTD, CLED @ Test & Measurements Solutions Poland
    Solved!
    Go to Solution.

    Thanks for your replay, I have tried to build it in my LabView Block Diagramm, es seems like this image.
    But the variable GetNumSubProperties ist always 0. Why?
    PS: I need only the variable "Step.Result.PassFail" from the last step, do you know, how can I get it? I think, it is maybe easier than read all the "Result".
    Attachments:
    ReadStepResultInLabview.JPG ‏39 KB

  • How can I read an ID-value from the LMS and insert this into an URL?

    Hi
    Right now I am struggling with a little problem. Hopefully anyone here knows the answer. For the latest course I am building (Captivate 6), it is necessary that at one point the course reads an ID-value from the LMS. After that, this ID should be inserted into an URL.
    To be more precisely: the ID must be read (getValue) from cmi.archive_id and inserted into an URL like that: http://.../archive.php?action=pdf&objectID=ARCHIVE_ID.
    Unfortunately I am more of a designer und less of a javascript-maestro (well...I am a javascript-noob to be precisely), therefore I am pretty clueless how to do that. I tried a simple executed action (run Javascript: cpEIGetValue('cmi.archive_id'); and after that open URL http://.../archive.php?action=pdf&objectID=ARCHIVE_ID), but...well...that didn't work.
    Any ideas?
    Thanks a lot in advance

    Think you'll find help looking at Jim Leichliter's website:
    http://captivatedev.com/
    He has great tutorials about JavaScript and also a widget that allows to enter a variable in URL's
    Lilybiri

  • Looking for pure Java API to read metadata from an MP4 file.

    Hi, I am looking for a pure Java api that can read MP4 metadata. I have been trying to look online for one but have not found anything
    suitable. If there are no good api's, can someone point me to resources on how to parse metadata from an MP4, tutorials would be great
    as well. I have looked online for that as well but have not found much. Any help would be greatly appreciated.

    Cross posted
    http://www.java-forums.org/new-java/59652-looking-pure-java-api-read-metadata-mp4-file.html
    http://www.coderanch.com/t/580833/Streams/java/Looking-pure-Java-API-read
    http://stackoverflow.com/questions/10568588/looking-for-pure-java-api-to-read-metadata-from-an-mp4-file
    db

  • Any java API to get the metadata for a deployed bpel process in soa/bpm11g?

    Hi,
    Just wonder if this is possible, that there is some existing java api to retrieve the metadata (containing activities, isSynchrous, version information etc) for a deployed bpel process? If not, is there any other way to achieve this goal ( or example query database table directly)?
    I can only find this link for soa11g java api. I am able to invoke the bpel process using this API(direct binding) from java client.
    http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e10659/index.html?overview-tree.html
    Any help will be greatly appreciated.
    Thanks,
    Bin

    What I find so far:
    1. can get some process property values from ComponentInstance class, see its api.
    http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e10659/oracle/soa/management/facade/ComponentInstance.html
    Please refer http://blogs.oracle.com/soabpm/2009/07/soa_suite_11g_api_tricks_part.html of how to get the component instance (contain the bpel process) from a composite object
    2. in dev_soainfra database schema, the CUBE_INSTANCE table contains most of soa bpel components information. The BPM_CUBE_PROCESS table seems to contain only the process defined in a bpm application. This sounds a little confused, if we want to develop a bpel application, should it be put in soa or bpm application and what is the difference?
    Please feel free to correct any mistakes here.

  • How can i get the all values from the Property file to Hashtable?

    how can i get the all values from the Property file to Hashtable?
    ok,consider my property file name is pro.PROPERTIES
    and it contain
    8326=sun developer
    4306=sun java developer
    3943=java developer
    how can i get the all keys & values from the pro.PROPERTIES to hashtable
    plz help guys..............

    The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
    InputStream is = new FileInputStream("tivoli.properties");
    props.load(is);

  • Need help Take out the null values from the ResultSet and Create a XML file

    hi,
    I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
    a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
    takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
    from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
    null values to XML File. When i run the program it works alright and adds the null and not null values to
    the file. But when i pass the boolean value to take out the null values it would not take it out and adds
    the null and not null values.
    Please look at the code i am posing. I am showing step by step where its not adding the null values.
    Any help is always appreciated.
    Thanks in advance.
    ============================================================================
    Frame1 Class
    ============
    public class Frame1 extends JFrame{
    private JPanel contentPane;
    private XQuery xQuery1 = new XQuery();
    private XYLayout xYLayout1 = new XYLayout();
    public Document doc;
    private JButton jButton2 = new JButton();
    private Connection con;
    private Statement stmt;
    private ResultSetToXML rstx;
    //Construct the frame
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    //Component initialization
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    xQuery1.setSql("");
    xQuery1.setUrl("jdbc:odbc:SCANODBC");
    xQuery1.setUserName("SYSDBA");
    xQuery1.setPassword("masterkey");
    xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
    jButton2.setText("Get XML from DB");
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(java.lang.ClassNotFoundException ex) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(ex.getMessage());
    try {
    con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
    stmt = con.createStatement();
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    jButton2.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    jButton2_actionPerformed(e);
    contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
    //Overridden so we can exit when window is closed
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton2_actionPerformed(ActionEvent e) {
    try{
    OutputStream out;
    XMLOutputter outputter;
    Element root;
    org.jdom.Document doc;
    root = new Element("PINFO");
    String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
    ResultSet rs = stmt.executeQuery(query);
    /*===========This is where i am passing the ResultSet and boolean=======
    ===========value to either add the null or not null values in the file======*/
    rstx = new ResultSetToXML(rs,true);
    } //end of try
    catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    ======================================================================================
    ResultSetToXML class
    ====================
    public class ResultSetToXML {
    private OutputStream out;
    private Element root;
    private XMLOutputter outputter;
    private Document doc;
    // Constructor
    public ResultSetToXML(ResultSet rs, boolean checkifnull){
    try{
    String tagname="";
    String tagvalue="";
    root = new Element("pinfo");
    while (rs.next()){
    Element users = new Element("Record");
    for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
    tagname= rs.getMetaData().getColumnName(i);
    tagvalue=rs.getString(i);
    System.out.println(tagname);
    System.out.println(tagvalue);
    /*============if the boolean value is false it adds the null and not
    null value to the file =====================*/
    /*============else it checks if the value is null or the length is
    less than 0 and does the else clause in the if(checkifnull)===*/
    if(checkifnull){ 
    if((tagvalue == null) || tagvalue.length() < 0 ){
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    else{
    users.addContent((new Element(tagname).setText(tagvalue)));
    root.addContent(users);
    out=new FileOutputStream("c:/XMLFile.xml");
    doc = new Document(root);
    outputter = new XMLOutputter();
    outputter.output(doc,out);
    catch(IOException ioe){
    System.out.println(ioe);
    catch(SQLException sqle){

    Can someone please help me with this problem
    Thanks.

  • MDM API to read the Record Key Mapping table

    Hi,
    Does anybody know what class/method I can use to read the Record Key Mapping table?
    For the Business Partner table the Key Mapping table has this columns:
    <u>Default / MDM Partner ID / Remote System / Key</u>
    I have everything but the Key. How can I read it?
    Thanks in advance,
    Diego.

    GetKey Mapping is one of the available Web Services as of SP4.
    Else you could use the Java API to get the Key Mapping.
    <b>CatalogData class</b> has the following method
    <b>GetKeyMapping</b>
    public java.lang.String[][] GetKeyMapping(java.lang.String agency,
                                              java.lang.String table,
                                              int[] recordIDs,
                                              boolean isDefaultKeyOnly)
                                       throws StringExceptionRetrieves the key mapping for each record.
    Parameters:
    agency - the agency name.
    table - the table name.
    recordIDs - the list of records.
    isDefaultKeyOnly - True to retrieve only the default value, False to all key values.
    Returns: the key values for each record.

  • Does java api allow access the ethernet card directly

    i m working on cluster computing. i like to code in java. i need to send object from one single machine to other machines in a university computer lab. i would like to send the objects very efficiently and fastly. i used java.net and also java.nio. but i think it would be fast more if i could directly access the ethernet card- read from and write to the network interface card directly.

    does java api allow access the ethernet card directlyNo.

  • Finding the smallest value from an array

    Hi there :)
    I started learning Java a few days ago and have now run into my first problem :p
    I am using Netbeans on Mac OS X.
    I need to find the smallest value from an array. So far I've had no luck. Any suggestions would be fantastic.
    The code so far:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    public class Main {
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
        public static void main(String[] args) {
            int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
            int O = A.length - 3;
            int B = A[0] + A[1] + A[2] + A[3] + A[4] + A[5] + A[6] + A[7] + A[8] + A[9] + A[10] + A[11] + A[12] + A[13] + A[14];
            A[15] = B;  // Stores the sum of the integers in A[15]
            int C = B / O;
            A[16] = C;  // Computes and stores the average in A[16]
            int D = 101;
                if (A[0] < A[1]) { D = A[0]; }
                else { D = A[1]; }
                if (A[1] < A[2]) { D = A[1]; }
                else { D = A[2]; }
            System.out.println("There are " + O + " numbers in the Array");
            System.out.println("Those numbers add up to " + B + ".");
            System.out.println("The average of those numbers is " + C + ".");
            System.out.println("The smallest value in the array is " + D + ".");
    }The code is incomplete, but it works so far. The problem is I know there must be an easier way. SAVE ME :)

    OK :)
    Just thought I should show you the output as to help anyone else with the same problem:
    * Math Problems
    * Created on May 4, 2007, 10:54 AM
    * PROJECT 1: - IN PROGRESS
    * Create a program that allows you to create an integer array of 18 elements with the following values
    * 3, 2, 4, 5, 6, 4, 5, 7, 3, 2, 3, 4, 7, 1, 2, 0, 0, 0
    *  - The program computes the sum of elements 0 to 14 and stores it in element 15                              // COMPLETED
    *  - The program computes the average and stores it in element 16                                              // COMPLETED
    *  - The program finds the smallest value from the array and stores it in element 17                           // COMPLETED
    * PROJECT 2: - TO DO
    * Write a program that accepts from the command line and prints them out. Then use a for loop to print
    * the next 13 numbers in the sequence where each number is the sum of the previous two. FOR EXAMPLE:
    *  - input>java prob2 1 3
    *  - output>1 3 4 7 11 18 29 47 76 123 322 521 843 1364
    * PROJECT 3: - TO DO
    * Write a program that accepts from the command line two numbers in the range from 1 to 40. It then
    * compares these numbers against a single dimension array of five integer elements ranging in value
    * from 1 to 40. The program displays the message BINGO if the two inputted values are found in the array
    * element. FOR EXAMPLE:
    *  - input>java prob3 3 29
    *  - output>Your first number was 3
    *  -        Your second number was 29
    *  -        Its Bingo!  // This message if 3 and 29 are found in the array
    *  -        Bokya!      // This message if 3 and 29 are not found in the array
    *  -        The array was 7 5 25 5 19 30
    * PROJECT 3 EXTENSION: - OPTIONAL
    * Generate the array of 5 unique integers using random numbers
    package mathproblems;
    * @author Mohammad Ali
    import java.util.Arrays;
    public class Main { 
        /** Creates a new instance of Main */
        public Main() {
         * @param args the command line arguments
         public static void main(String[] args) {
                  int A[]={3,2,4,5,6,4,5,7,3,2,3,4,7,1,2,0,0,0};
              Arrays.sort(A);
              System.out.println("The smallest value in the array is " + A[0] + ".");
              int num = A.length;
              System.out.println("There are " + num + " values in the Array.");
              int sum = 0;
              for (int i = 0; i < A.length; i++) {
                   sum+=A;
              System.out.println("Those numbers add up to " + sum + ".");
              double d = (double)sum/num;
              System.out.println("The average value of those numbers is " + d + ".");
    What Iearned:
    1) How to create for loops properly
    2) How to import java.util.Arrays ( =D )
    3) How to get a more accurate average using double instead of int
    4) This forum is the best and has very helpful people 24/7 ( =D)
    Thanks Again,
    Mo.

Maybe you are looking for

  • Error while trying to modify a Qualified Lookup Value.

    Hello, I have the following structure: Vendor <-- Main Table vendorName vendorType BankDetails <-- Qualified Table BankDetails (Table) Country   (non-qualifier value) bankKeyCode (cualifier value) Country code name I am trying to modify the BankDetai

  • Digital Signature :- Changing contents in Original and revoking Diital Sign

    Hi We have a requirement as follows 1) There are 4 approval levels for a status A2 (Approval 2) 2) Levels are S1, S2, S3, S4 where S4 is the Program Director who finally releases the status 3) Initially S1 wud approve, then S2, then S3 and so on. Fin

  • File available with list of customized seeded forms on Linux?

    Hello, Does anyone know which file on Linux keeps track of the customized seeded forms? This list will be used to give a warning when applying a patch which contains conflicts. Thanks for your response! Guy Edited by: guyb on 6-mei-2010 5:33 Edited b

  • Authorization Tools

    Hello, Do you know any extra add-on or supporting tools for authorizations? Perhaps which can help us maintain the org-level for each user in an easier way? Any idea is welcome. Regards Florian

  • Inclusive / exclusive keyword hierarchy

    Keywords in a hierarchy should be inclusive or exclusive of child keywords if desired (parent-child relationships). For example, if I have a brother named Jack, and he has a wife name Jill and a son named Bill I might created the following hierarchy