Unable to execute a command line command using Java

I am trying to run a command to add a group name. It is executed in command prompt of Windows 2003/2000
Say this is the command I want to execute:
net localgroup LordSM /add
Here LordSM is the group name.
I wrote the following code but it does not seem to work. Please suggest.
String ABC=Value1TextField.getText();
Value2Label.setText("Value is now " + ABC);
// Above is to get value from a JText Field
// Below is the code to run command for adding a group name to a System.
String ExecutedCmd = "net localgroup " + ABC + "/add";
Process p = Runtime.getRuntime().exec(ExecutedCmd);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null)
{ System.out.println(s); }
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null)
{ System.out.println(s); }
I am trying to run a command to add a group name. It is executed in command prompt of Windows 2003/2000
Say this is the command I want to execute:
net localgroup LordSM /add
Here LordSM is the group name.
I wrote the following code but it does not seem to work. Please suggest.
String ABC=Value1TextField.getText();
Value2Label.setText("Value is now " + ABC);
// Above is to get value from a JText Field
// Below is the code to run command for adding a group name to a System.
String ExecutedCmd = "net localgroup " + ABC + "/add";
Process p = Runtime.getRuntime().exec(ExecutedCmd);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null)
{ System.out.println(s); }
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null)
{ System.out.println(s); }
It does not seem to work means, that no Standard Error is defined, when it executes and group name is not added as well. The following is JUnit Test Result: Hope it gives a better idea of the problem I am facing:
compile:
run:
Here is the standard output of the command:
Here is the standard error of the command (if any):
The syntax of this command is:
NET LOCALGROUP [groupname [/COMMENT:"text"]] [DOMAIN]
groupname {ADD [/COMMENT:"text"] | /DELETE} [DOMAIN]
groupname name [...] {ADD | /DELETE} [DOMAIN]
Got it
BUILD SUCCESSFUL (total time: 10 minutes 49 seconds)
I had even tried this:
Runtime rt =Runtime.getRuntime();
String[] cmd = new String[3];
cmd[0] = "cmd.exe";
cmd[1]="net localgroup";
cmd[2] =ABC + "/add";
rt.exec(cmd);
but again, it does not give any error as such, but it does not create the group name either. Please suggest. We can see the group names that are added on right clicking My Computer Icon and click Manage and then go to User & Group section. On executing either of the code nothing happens.
Thanks

Duplicate post:
http://forum.java.sun.com/thread.jspa?threadID=5203526&messageID=9812067#9812067

Similar Messages

  • To run a report from command line, when using jdbc-odbc bridge

    Hi,
    How to run a report from command line, when using jdbc-odbc bridge?
    Usually with tns, we do by "rwrun module=<> userid=<user>/<passwd>@tns".
    with odbc, we do by "rwrun module=<> userid=<user>/<passwd>@odbc:DSN"
    Please specify, what is command line arguments for jdbc-odbc bridge driver?
    Environment : Oracle 9i Report Builder on WinNT
    Database : Sybase
    Regards,
    Ramanan

    Hello Ramanan,
    Report Builder : connect JDBC Query in Report Builder is to through Connection Dialog in JDBC Query Editor. User can use a Sign on parameter (can use, default : P_JDBCPDS or can create new) to connect to JDBC Data Source. Connection once made will be mentioned and will be reused through out Reports Builder.
    JDBC PDS allows user to connect one or more same or different kind of databases.
    While running report through runtime or Server, user can pass the sign on parameter(connection string) value, like any other user parameter.
    Syntax for connection string : <username>/<password>@databaseURL . The syntax of database part of connection string depend on the type of JDBC Driver used to connect to Data Source while designing the JDBC Query. databaseURL refer to the location of the database and its format depend on the JDBCPDS river selected in design time while creating the JDBC Query.
    rwrun eg :
    rwrun report=jdbc_odbc.rdf destype=file desname=output.html desformat=html P_JDBCPDS=scott/tiger@database
    Server eg :
    http://server.com:8888/servlet/RWServlet?server=MyReportServer+report=jdbc_odbc.rdf+destype=cache+desformat=html+P_JDBCPDS=scott/tiger@database
    http :
    Please see ORACLE_HOME/reports/conf/jdbcpds.conf for more information.
    With Regards
    Reports Team

  • Custom splash screen only shows up when command line is used...

    Hi,
    Everything in my Java web start application works perfectly but, the custom splash screen only shows up when command line is used ("C:\Program Files (x86)\Java\jre7\bin>javaws -verbose http://www.xxx.eu/AcSentVivresCrus/AcSentJnlp/AcSent.jnlp"), if I use the shortcut on the desktop or in the start menu, the Java 7 splash screen shows up (tested under Windows Vista and Seven). Does someone have any clues?
    Thanks...
    My jnlp file :
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="6.0+" href="AcSent.jnlp">
      <information>
        <title>AcSent : Commande de repas</title>
        <description>AcSent - Commande de repas</description>
        <vendor>AcSent</vendor>
        <homepage href="http://www.xxx.eu" />
        <icon href="acSentIconBiseau.png" />
        <icon href="splashAcSentRC.png" kind="splash" />
        <shortcut online="true">
          <desktop />
          <menu submenu="AcSent" />
        </shortcut>
      </information>
      <security>
        <all-permissions />
      </security>
      <resources>
        <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="128m" />
        <jar href="AcSentJnlpProgressIndicator.jar" download="progress" />
        <jar href="AcSentJnlp.jar" main="true" version="1.0" />
        <property name="jnlp.packEnabled" value="true" />
        <property name="jnlp.versionEnabled" value="true" />
      </resources>
      <application-desc name="AcSent" main-class="eu.acsent.jnlp.AcSentApplication"
           progress-class="eu.acsent.jnlp.progressindicator.CustomProgress"> 
      </application-desc>
    </jnlp>

    Hi again,
    I made some researches :
    - The link in the generated shorcuts ("C:\Windows\SysWOW64\javaws.exe -localfile -J-Djnlp.application.href=http://www.xxx.eu/AcSentVivresCrus/AcSentJnlp/AcSent.jnlp "C:\Users\Arnaud\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\46\69c1e9ee-1f252d1a") is not the same as the one I use in the command line ("C:\Program Files (x86)\Java\jre7\bin>javaws -verbose http://www.xxx.eu/AcSentVivresCrus/AcSentJnlp/AcSent.jnlp"). Is there a way in the the JNLP file to tell how to generate shortcuts (not the icon, etc., but command line options)?
    - This sample (https://blogs.oracle.com/thejavatutorials/entry/changing_the_java_web_start) displays the splash screen when I click on the the generated shortcuts (I use Windows 7). I have copied the ButtonDemo jar file and the JNLP file on my IIS web server (Windows 2008 Server), this time the splash screen does not show up when I click the generated shortcuts but always shows up when I use the command line. Can someone tell me if it is a trouble with IIS ?
    Thanks again...

  • How are Windows Server Backup and Command Line Tools used in vCSHB installation?

    How are Windows Server Backup and Command Line Tools used during the installation of vCSHB?  Is it required in all types of deployments (PtoV, VtoV, PtoP)? Is it used to create the files that are put in the file share for the second node to use during vCSHB installation or is it only used during a vCSHB clone operation of a Physical to Physical deployment?  Are these tools not used in some deployments?

    You need Windows Server Backup installed on source and destination, and during the installation of vCSHB the installer will invoke the wbadmin (Windows Server Backup Utility) and will backup configuration and application data (application data is optimal but can decrease the sync time after installation of secondary node). On the secondary node you will need only run the vCSHB installer and everything will be restored.
    Check this blog entry for some more info about some problems in P2P deployment: http://www.vcoportal.de/2013/12/vmware-vcenter-server-heartbeat-restore-on-a-second-node-a-journey/

  • How do shutdown the weblogic server from the command line prompt using web logic 8.1

    I%u2019m currently using weblogic 6.1, but I will upgrade to weblogic 8.1. In weblogic 6.1, the following statements will shutdown the weblogic instance from the command line:
    java weblogic.Admin -url t3://hostname:port -username system -password abc SHUTDOWN
    How do I shutdown the weblogic server from the command line prompt using web logic 8.1.
    Any help will be greatly appreciated.
    Maria

    Maria <[email protected]> wrote:
    How do I shutdown the weblogic server from the
    command line prompt using weblogic 8.1?Greetings Maria! Use this document, located here:
    http://edocs.bea.com/wls/docs81/admin_ref/cli.html#1131733
    Hope this helps...
    Brian J. Mitchell
    Systems Administrator, TRX
    email: [email protected]
    office: +1 404 327 7238
    mobile: +1 678 283 6530

  • HiQ doesn't execute scripts and command line commands

    I am running HiQ pro 4.5 on Windows 2000 SP 2. Whenever I enter a command line command, e.g. "1+1", HiQ reports "no error reported" and doesn't execute the command. When I enter the same command again, HiQ tells me that a semicolon is missing.
    When I try to execute a script, HiQ reports "Fatal Script error on line -1".
    Anybody knows this behaviour and how to get HiQ running normally?

    I do have the same problem.

  • Command line commands

    Is there any class in the default java SDK for executing command line commands? I've been looking in the API but have been unsuccessful so far.
    Thanks.

    when i execute the command, the process created goes for half a minute or so, but the java program just ends straight away.
    is there any way to keep the java program open as long as the process is still running?

  • Command line command for combine jpeg files into a pdf file

    I want to learn if we have any command line sentence to combine jpg files.
    normally from the windows explorer window
    i can select all jpg files and when i click on right button on the window they shows Combine supported files in acrobat and then i check if single file is selected and i clicked on combine files button.
    and then i put name of the file and press the save button.
    But i want to process this steps via command line commands.
    Can you show any answer to me.

    You don't say what version of Acrobat you are using, but I expect you could do it with Acrobat XI's Actions feature. Maybe even in 10.0. Since this is an enterprise deployment forum, I suggest you find a better forum and ask about Actions and Batch Processing.
    hth,
    Ben

  • Aerender error: "Unable to execute script at line 95. Window does not have a constructor"

    A BG Renderer user is getting this error when running aerender version 10.5.1x2:
    "Unable to execute script at line 95. Window does not have a constructor"
    The render proceeds but the process never completes which is preventing the rest of the BG Renderer notifications from triggering.  Any idea what this error means and how to fix it?
    Thanks,
    Lloyd

    I guess we'll have to wait for Adobe to answer what could be causing the transmission to drop on Line 95. Todd's out of the office for a month or two, but maybe someone else can shed some light.

  • Develop a command-line application using LabVIEW

    Hi,
             Is it possible to generate a command line(CLI) executable using LabVIEW? This CLI exe will be called with certain command line arguments by another application (written in Visual Basic). The LabVIEW Run time engine can be installed separately on the host PC.
    Thanks for your help
    Siddharth 
    Solved!
    Go to Solution.

    There is an example that ships with LabVIEW that shows how to read the command line arguements from an application. THe name of the VI is CommandLine.vi. It is extremely basic though. The power of command line arguements really comes from how you define and parse them. I recommend allowing your command line arguements to be order independent and that they require a label. For comand lines I prefer to use a single letter for the label. Full words are nice but then your command line gets very long. For the applications that we write we allow both the '/' (DOS/Windows style) and the '-' (Unix/Linux style) to designate a command line label.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Using Command Line Arguments with JAVA

    Hi,
    we are using an app called ImageMagick to scale and modify images before they are uploaded to a webserver.
    ImageMagick is called from our Objectiv-C app via
    command line.
    is there a way to this in Java?
    Regards
    Eckbert

    So, ur question is not developing a Java application that
    will do the 'image conversion'; but, your message
    conveys that u want to know how to invoke a Java program built by 'imagemagick' that takes command line arguments?
    Am I right?
    If that's the case, u must look into the documentation
    given along with the download'ed piece of software
    for identifying the 'starting point of the program'. i.e., the
    class that contains the 'main' method! And after you
    identify that class [Eg. ImageMagickStart] then you'll
    have to invoke as follows:
    [you must have Java installed in ur system!]
    c:>java ImageMagickStart
    If the program was written intelligently it must print all
    the command-line arguments required by the above
    program by executing the above command, and from that
    you can identify!
    -RK

  • How we run command line commands in oracle

    Hi,
    In sql server i have an option "xp_cmdshell" i can run windows commands e.g "dir " using query analyzer.
    How can i do same thing in oracle
    Thanks in advance.
    Regards
    Faheem

    > MY SELECT:select OSexec('dir') as STDOUT from dual;
    ERROR:-1command[dir] The handle is invalid.
    In the sample code, I've executed a Linux/Unix program called date, physical file /usr/bin/date.
    Is there a DATE.EXE or a DIR.EXE program that you can execute on Windows?
    No. Both DATE and DIR are commands of a program - a 32bit console program called CMD.EXE.
    Your confusion stems from thinking that OSEXEC is calling the Windows shell command line. It is not. It is not calling CMD.EXE and passing Window Shell Commands to CMD.EXE.
    OSEXEC is calling, via Java, the Win32 API call called CreateProcess(). This is a call to the Win32 kernel. It requests the kernel to load an executable program as a process image.
    The kernel expects an EXE (or executable) file to load. You are passing it a command from a program. You just as well can pass it a Java command, a MS Access Basic Command, an Excel Macro, etc... Same thing. The kernel has no idea that this "command" needs another program to be loaded, and that command be "passed" somehow to that program.
    So, you need to call CMD.EXE via OSEXEC. And you can pass parameters to it. Open a Command Console and type cmd /? for help on the command line switches and parameters for CMD.EXE.
    I believe the following should work:
    SQL> select OSEXEC( 'c:\windows\system32\cmd.exe /c date /t') from dual;

  • Program runs in eclipse but in command line I need java -cp .

    I thought I understood what the classpath variable was all about. I thought it was the directory where the java standard classes were, namely the bin directory of your Java directory. However I've been using Eclipse for the first time and the programs compile and run fine in Eclipse, but in my command line I need to do java -cp . [compiled class] to make it run. Can somebody explain why? Doesn't java normally look in the current directory for the executing classes?
    Also I just checked out my CLASSPATH variable and I see C:\Program Files\Java\jre1.5.0_04\lib\ext\QTJava.zip which doesn't seem right to me. Can somebody explain what this is all about? I thought when you installed the Java SDK (JDK) it sets your classpath and everything.

    I thought I understood what the classpath variable
    was all about. I thought it was the directory where
    the java standard classes were, namely the bin
    directory of your Java directory.There is nothing correct about this statement. The classpath defines where your classes, packages and JARs are. /bin should be in PATH, and the J2SE standard classes don't need to be referenced in any variable.
    However I've been
    using Eclipse for the first time and the programs
    compile and run fine in Eclipse, but in my command
    line I need to do java -cp . [compiled class] to make
    it run. Can somebody explain why?Because the Eclipse project defines a classpath of its own (see Proprties-> Build Path) and doesn't give a damn about any system variable.
    Doesn't java
    normally look in the current directory for the
    executing classes?No. It looks in the classpath, nowhere else.
    Also I just checked out my CLASSPATH variable and I
    see C:\Program
    Files\Java\jre1.5.0_04\lib\ext\QTJava.zip which
    doesn't seem right to me. Can somebody explain what
    this is all about? Another superfluous setting. Libs in /lib/ext are automatically in the classpath.
    I thought when you installed the
    Java SDK (JDK) it sets your classpath and everything.How would it know where your classes are?

  • Issue with variables and white space in powershell script that calls a command line command

    Guys,
    I have a question regarding this script. Each time I run it, it creates the share, but with a space after it. Also I need help figuring out how to put in the variable for the folder path.
    Below is the code
    $Users=Import-Csv C:\users2.csv
    foreach($User in $Users){
         $User.SNCORP
         $User.HPB
         $User
         cmd /c "net share "$User.SNCORP"=D:\Users\"$User.HPB" /grant:Everyone,FULL"
    The csv file looks like this
    HPB,SNCORP
    ccarter,carterch$
    This is my output in powershell
    PS C:\> .\shareflip.ps1
    carterch$
    ccarter
    HPB                                                         SNCORP
    ccarter                                                     carterch$
    The syntax of this command is:
    NET SHARE
    sharename
              sharename=drive:path [/GRANT:user,[READ | CHANGE | FULL]]
                                   [/USERS:number | /UNLIMITED]
                                   [/REMARK:"text"]
                                   [/CACHE:Manual | Documents| Programs | BranchCache | None]
              sharename [/USERS:number | /UNLIMITED]
                        [/REMARK:"text"]
                        [/CACHE:Manual | Documents | Programs | BranchCache | None]
              {sharename | devicename | drive:path} /DELETE
              sharename \\computername /DELETE
    Any help is greatly appreciated. 
    Christopher

    There is no need to use cmd /c. You should be able to use:
    net share "$($User.SNCORP)=D:\Users\$($User.HPB)" "/grant:Everyone,Full"
    Use showargs.exe (from the article) at the beginning of this line to see the command line PowerShell is actually running (very useful for troubleshooting).
    -- Bill Stewart [Bill_Stewart]

  • Permission problems with command line CVS and Java CVS App

    Greetings,
    I'm part of a moderately sized website development team which recently upgraded to MacBook Pros (dual core) running OS 10.4.9. One of the primary tools we use in our day to day work is the open source concurrent versioning system (CVS). We've noticed a distressing issue running CVS on our macbook pros: there seems to be a problem with the way these new machines handle permissions on the directories/files that CVS uses to manage files.
    The error occurs when the CVS application, in this case both command line CVS and GUI CVS application named SmartCVS, tries to rename a temporary file named Entries~ to its new name Entries (no ~). It looks like this:
    java.io.IOException: Could not rename file
    /Users/[USER]/Sites/[MODULE]/lib/CVS/Entries~ to
    /Users/[USER]/Sites/[MODULE]/lib/CVS/Entries
    at smartcvs.JP.a(SourceFile:125)
    at smartcvs.JP.a(SourceFile:113)
    We've noticed that if we open up a get info window on the directory we're downloading, and choose "Apply to enclosed items" right when we start the download process, the issue will be resolved, presumably because the permissions are being set on the subdirectories as the download is taking place.
    We've checked the permissions on the overall ~/Sites/ directory numerous times, and they always seem to be set correctly as drwxr-xr-x. It's within this folder that CVS creates a directory with the CVS module name and downloads all the contained files, so we don't see why it would be having issues completing this successfully. We also checked to ensure the GUI CVS application is running under the current user on the machine: it does.
    Has anyone run into issues like this in the past? Is there more information I could provide to further clarify the problem we're having?
    Thanks for any input you have!

    Thanks for asking Jeff, yes one place we are seeing this error is Java application SmartCVS, though the results posted here are from a normal command line CVS checkout.
    ===
    Checkout command:
    cvs co [MODULE]
    ===
    Error:
    cvs [checkout aborted]: cannot rename file CVS/Entries.Backup to CVS/Entries: No such file or directory
    ===
    ID:
    uid=502([USER]) gid=502([USER]) groups=502([USER]), 81(appserveradm), 79(appserverusr), 80(admin)
    ===
    LS -ALN
    Computer:~/Sites [USER]$ ls -aln
    drwxr-xr-x 28 502 502 952 Jun 4 13:11 Sites
    Computer:~/Sites/[MODULE] [USER]$ ls -aln
    drwxr-xr-x 38 502 502 1292 Jun 4 13:33 www_root
    Computer:~/Sites/[MODULE]/www_root [USER]$ ls -aln
    drwxr-xr-x 32 502 502 1088 Jun 4 13:33 [SUBDIR1]
    Computer:~/Sites/[MODULE]/www_root/[SUBDIR1] [USER]$ ls -aln
    drwxr-xr-x 5 502 502 170 Jun 4 13:33 [SUBDIR2]
    Computer:~/Sites/[MODULE]/www_root/[SUBDIR1]/[SUBDIR2] [USER]$ ls -aln
    drwxr-xr-x 4 502 502 136 Jun 4 13:33 [SUBDIR3]
    Computer:~/Sites/[MODULE]/www_root/[SUBDIR1]/[SUBDIR2]/[SUBDIR3] [USER]$ ls -aln
    drwxr-xr-x 6 502 502 204 Jun 4 13:33 CVS
    Computer:~/Sites/[MODULE]/www_root/[SUBDIR1]/[SUBDIR2]/[SUBDIR3]/CVS [USER]$ ls -aln
    total 32
    drwxr-xr-x 6 502 502 204 Jun 4 13:33 .
    drwxr-xr-x 4 502 502 136 Jun 4 13:33 ..
    -rw-r--r-- 1 502 502 45 Jun 4 13:33 Entries
    -rw-r--r-- 1 502 502 45 Jun 4 13:33 Entries.Log
    -rw-r--r-- 1 502 502 48 Jun 4 13:33 Repository
    -rw-r--r-- 1 502 502 63 Jun 4 13:33 Root
    MacBook Pro / MacPro Mac OS X (10.4.9)

  • Passing command line argument in java

    I was writting a calendar pogram that took user input from the command line. What I want to know is how can I write my program so that if the user doesn't enter the info. it will automatically assign a value to the variable in the array, eg:
    if they typed: java calendarmonth 10 2005
    they would get a printout for the calendar month of October 2005, but I want it so that if they typed
    java calendarmonth 10
    it would automatically assign they year to be the current year, and if they typed
    java calendarmonth
    it would auctomattically assign the current month and year to the program, heres the source code:
    import javax.swing.JOptionPane;
    import java.util.*;
    public class calendarmonth {
         /** Main method */
         public static void main(String argv[]) {
              String monthString = argv[0];
              int month = Integer.parseInt(monthString);
              String yearString = argv[1];
              int year = Integer.parseInt(yearString);
              printMonth(year, month);
              if (month > 12) {
              System.out.println("Invalid Number Please Try");
         //code to perform OK action
              /** Print the calendar for a month in a year */
              static void printMonth(int year, int month) {
                   //Print the heading of the calendar
                   printMonthTitle(year, month);
                   //Print the headings of the calendar
                   printMonthBody(year, month);
              /** Print the month title, e.g., May, 1999 */
              static void printMonthTitle(int year, int month) {
                   System.out.println(" " + getMonthName(month)
                   + " " + year);
                   System.out.println("------------------------------");
                   System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
                   /** Get the English name for the month */
                   static String getMonthName(int month) {
                        String monthName = null;
                        switch (month) {
                             case 1: monthName = "January"; break;
                             case 2: monthName = "February"; break;
                             case 3: monthName = "March"; break;
                             case 4: monthName = "April"; break;
                             case 5: monthName = "May"; break;
                             case 6: monthName = "June"; break;
                             case 7: monthName = "July"; break;
                             case 8: monthName = "August"; break;
                             case 9: monthName = "September"; break;
                             case 10: monthName = "October"; break;
                             case 11: monthName = "November"; break;
                             case 12: monthName = "December"; break;
                        return monthName;
    /** Print month body*/
    static void printMonthBody(int year, int month){
    //Get start day of the week for the first date in the month
    int startDay = getStartDay(year, month);
    //Get number of days in the month
    int numberOfDaysInMonth = getNumberOfDaysInMonth(year, month);
    //Pad space before the first day of the month
    int i = 0;
    for (i = 0; i < startDay; i++)
         System.out.print(" ");
    for (i = 1; i <= numberOfDaysInMonth; i++) {
    if (i < 10)
    System.out.print(" " + i);
    else
    System.out.print(" " + i);
    if ((i + startDay) % 7 == 0)
         System.out.println();
         System.out.println();
    /** Get the start day of the first day in a month */
    static int getStartDay(int year, int month) {
    //Get total number of days since 1/1/1800
    int startDay1800 = 3;
    int totalNumberOfDays = getTotalNumberOfDays(year, month);
    //Return the start day
    return (totalNumberOfDays + startDay1800) % 7;
    /** Get the total number of days since Jan 1, 1800 */
    static int getTotalNumberOfDays(int year, int month) {
    int total = 0;
    // Get the total days from 1800 to year - 1
    for (int i = 1800; i < year; i++)
    if (isLeapYear(i))
    total = total + 366;
    else
    total = total + 365;
    // Add days from Jan to the month prior to the calendar month
    for (int i = 1; i < month; i++)
    total = total + getNumberOfDaysInMonth(year, i);
    return total;
    /** Get the number of days in a month */
    static int getNumberOfDaysInMonth(int year, int month) {
    if (month == 1 || month == 3 || month == 5 || month == 7 ||
    month == 8 || month == 10 || month == 12)
    return 31;
    if (month == 4 || month == 6 || month == 9 || month == 11)
    return 30;
    if (month == 2) return isLeapYear(year) ? 29 : 28;
    return 0; // If month is incorrect
    thanks
    /** Determine if it is a leap year */
    static boolean isLeapYear(int year) {
    return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
    }

    hey smallsouljah , to use code tags just put your code inside code tags.
    to create code tags you just need to press the button code that is located bellow the subject, this will automatically create code tags.
    System.out.println("testing");
    try yourself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • Wm - process posting change

    Hi experts, I am transfering a material from wm managed storage location to wm managed s.location.In MB1B with 311 mvt i have created material document.when i am doing lt06 two types of screens appearing.one is Process posting change:stock overiew wh

  • Generala item category group

    Dear all what is the difference between basic data 1 view- Gen item cat group  and Sales org 2 view-Item cat group I want sales bom to be exploded at the time of making sales order.For that need i maintaine MRP views for header level item and all dep

  • When syncing my Iphone4, Itunes shuts down.

    I get an error that Windows will find a solution if one is available.  I performed a sync about 5 times before it would sync all the music.  Then, it would shut down during the pictures part of the sync.  Finally, I unchecked "sync videos" and it com

  • Preview pane on right

    Is there any way to set up the mail window so that you have 3 columns? • Folders list • Messages • Preview pane Similar to the way you can on the iPad?

  • Scratch disk on external drive

    How do you get FCE to store captured media onto the external drive? I believe the scratch disk folder is where media is stored, so do I drag folders to the external drive? The drive has been formated to Mac.