[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

System Programming

40K

Solutions

19K

Contributors

Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.

Share tech news, updates, or what's on your mind.

Sign up to Post

try{
			
			previouslyTaken = new DataDAO().testForPkgPreviouslyTaken(this....., TimeStamp);//gives true or false boolean value
		}
		catch (XYZExceptionException xyze)
		{
			if(xyze.getMessage().contains("999"))
			{
				LOGGER.error("item is PreviouslyTaken due to aa", xyze);
				errorCodes.add(XYZConstants.PREVIOUS_TAKEN_EXISTS);				
			}
			else if(xyze.getMessage().contains("888"))
			{
				LOGGER.error("item is PreviouslyDumped due to bb", xyze);
				errorCodes.add(XYZConstants.PREVIOUSLY_DUMPED);
			}
			else
			{
				throw new XYZException(xyze);
			}	
			return ;
		}
		LOGGER.info("previouslyTaken indicator from DB {}",previouslyTaken); //coming false t me
		
		if(!previouslyTaken){
		processIt();
		else
		LOGGER.info("item taken or dumped so update status to new)

Open in new window


i have above code in a method.

i never saw if else inside a catch in earlier.

why some one use if else inside catch
when the catch is thrown as try block simply return true or false

when it has 999 or 888 etc value in the xyze exception

please advise
0
CompTIA Cloud+
LVL 12
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Hello,
I have a FreeBSD and ubuntu server.
I crate a cronjob to execute in specific time. but the command that I do required a full privilege on system... so how I can make the cronjob work with root for example ?
thanks.
0
Hi

We need to regularly create system restore points on our user computers via command line.

The idea is to automate this process without deploying any 3rd party tools.

Step 1. Check if system restore is enabled on the computer. If it is not, enable it.
Step 2. Check the storage size allocated for system restore. If it is less than 6 GB, configure to to be 6 GB.
Step 3. Create a system restore point with a generic label e.g. "maintenance".
Step 4. Check if the system restore point got created or not by listing existing system restore points and comparing the labels with the generic label used in step3.


So this is the general idea of the script we want to create and I think I can do the other bits myself except for creating system restore point via command line.

I have tried the WMIC method, powershell method and everything else I can find on blogs and google search.

Most commands I run return the "execution successful" message.

But when I check manually if the system restore point got created or not by opening system restore GUI, I don't see the restore point created.

For the life of me I can't figure out what's going on.

So pls help !
0
I tried jsp custom tag example.

custom tag color is not changing even though i changed to blue or some other color it still shows default color as attached.

Index.jsp is

<%--
    Document   : index
    Created on : Nov 6, 2018, 1:41:41 PM
    Author     : saiganesh
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="mytags" uri="/WEB-INF/tlds/my_tags" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <mytags:formattag colour="blue" font_size="50" is_uppercase="false">
            this is ext hello custom tag
            </mytags:formattag>
    </body>
</html>



my_tags.tld is

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
  <tlib-version>1.0</tlib-version>
  <short-name>my_tags</short-name>
  <uri>/WEB-INF/tlds/my_tags</uri>
 
  <tag>
      <name>formattag</name>
      <tag-class>tags.FormatTag</tag-class>
      <body-content>scriptless</body-content>
      <attribute>
          <name>colour </name>
          <required>true</required>
      </attribute>
        <attribute>
          <name>font_size </name>
          <required>true</required>
      …
0
Hi Experts,
I'm looking for either a VB function, script or DOS command that should do the following
remove all spaces from the all column names of a given excel sheet (or CSV file).
this should combine two words into one like "visit date" column should become VisitDate.
Thanks
0
hi,

I build one stateless session bean example with presentation tier html inddex page and web tier servlet within ejb web project then business tier in the ejb project


<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <form action="ConverterServlet" method="POST">
              <input type="number" name="value"></br>
              <select name="type">
                    <option value="C2F">celcius to fahrenheit</option>
                    <option value="F2C">fahrenheit  to celcius</option>
              </select></br>
              <input type="submit" value="Convert">
        </form>
            
    </body>
</html>

Open in new window


do i not need to add close tags for input html element
<input type="submit" value="Convert">

also do i not need to ad begin tag for </br>

please advise

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;

import bean.ConverterBeanLocal;
import bean.ConverterBeanLocal.ConvertType;
import java.io.IOException;
import java.io.PrintWriter;

Open in new window

0
Hi Experts,
I'm looking for either code or script that will do the following
loop thru all files of specific folder, not including sub folders (folder should only contain CSV files).
delete all the contents of those files, but do not delete the file itself.
Thanks
0
Hi,
What can be reason to the below error, while it only happens when I deployed the same project to https (everything is fine if I deploy it to http)?

Server Error in '/RegRec2' Application.
The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.]
   System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper) +258
   System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) +497
   System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +100
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection 

Open in new window

0
Hi,
I want to correct the background color of the highlighted area below. How?
34d.pngto this page
http://www.searchhouselive.com/RegRec2/?id=18&user_abbr=mc2&readonly=n

It is not affecting but I've put
.well {
    background-color: rgb(22, 105, 173);
}

Open in new window

to the css file.
1
Hi Experts,

I have the following command running as a batch file (on task scheduler) in an hourly bases.
xcopy "C:\Users\bfuchs\Dropbox\Caspio\caspiotables.zip" f:\Conversion\Caspio\ /y

Open in new window


would like to have this running in another pc as well as a backup.

However would prefer to have the following modifications

1- To first check for date/time that file f:\Conversion\Caspio\caspiotables.zip when it was modified, if it was not within the hour then perform the task.
2- Get an email informing it was done (so i know the 1st one failed).

Thanks in advance.
0
CompTIA Security+
LVL 12
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

In short, I would say:

A flag is a predefined bit or bit sequence that holds a binary value.

A mode is a distinct setting.

So it's not always possible to replace the term "mode" by "flag". This is only possible if it's about a binary value. I got confused by these terms when reading:

http://man7.org/linux/man-pages/man2/open.2.html

The argument flags must include one of the following access modes:
O_RDONLY, O_WRONLY, or O_RDWR.

The file creation flags are O_CLOEXEC,
O_CREAT, O_DIRECTORY, O_EXCL, O_NOCTTY, O_NOFOLLOW, O_TMPFILE, and
O_TRUNC.

The file status flags are all of the remaining flags listed
below.

Why they just don't say:

The file access flags are O_RDONLY, O_WRONLY, and O_RDWR.

Why they suddenly use a different term when it's about "access"? Probably behind the scenes it's also just about a binary value, right? Probably all O_VARIABLE's above are 0 or 1.

And see: https://en.wikipedia.org/wiki/File_descriptor

This table records the mode with which the file (or other resource) has been opened: for reading, writing, appending, and possibly other modes.

So Wikipedia uses the term "mode" only (and not flag). At least they are consistent, because they call them all "modes".

Is there a specific reason why sometimes mode is used and something flag (while it's about the same thing)? I would stay, be at least consistent to avoid confusion.
0
I previously installed Driver Genius and now i want to remove it.   It shows up in the system tray, but it is not listed in the  installed programs in Control Panel.   How do I remove it completely?
0
dup2(int oldfd, int newfd);

Open in new window


This is an equivalent of:

close(int newfd);
dup(int oldfd);

Open in new window


By closing "newfd" first, it becomes the lowest-numbered unused file descriptor (normally). Because of that the oldfd is copied to newfd (dup system call). So far, everything is clear.

Now see: http://codewiki.wikidot.com/c:system-calls:dup2


dup2 is a system call similar to dup in that it duplicates one file descriptor, making them aliases, and then deleting the old file descriptor.

Actually I don't think the old file descriptor will be deleted?

See: http://man7.org/linux/man-pages/man2/dup.2.html

After a successful return, the old and new file descriptors may be used interchangeably.

If the old file descriptor will be deleted, then they would not say something like that. Is wikidot.com just wrong about this?
0
I'm trying to understand the structure of the open file table. During this search I'm reading things that look like (for me) they are in contrast with each other.

In a system there is a:

File descriptor table:
This table is located in user space and is associated with a certain process (per-process).

Open file table:
This table is located in kernel space and is associated with all processes (process-wide).

Entries in the file descriptor table point to the open file table. This all is clear. Now let's go to the structure of these tables. For example, see: https://elixir.bootlin.com/linux/v3.18/source/include/linux/fdtable.h#L24

struct fdtable {
        [...]
};

Open in new window


And:

/*
 * Open file table structure
 */
struct files_struct {
        [...]
};

Open in new window


Also this is clear. But now see for example: http://www.andrew.cmu.edu/user/gkesden/ucsd/classes/sp17/cse291-a/applications/ln/lecture5.html

Per Process File Information


struct files_struct { /* kept within task_struct (PCB) */
        [...]
};

Here they are talking about files_struct when it's about "per process file information". I don't understand this, because the open file table is process-wide. This is for example what they are saying:

The count variable tracks the number of files the process has open

But imagine ... two different processes point to the same entry in the open file table. I think …
0
By default, the first three rows of a "file descriptor table" consists of:

FD 0 (standard input,  associated with keyboard)
FD 1 (standard output, associated with screen)
FD 2 (standard error,  associated with screen)

Open in new window


These file descriptors point to one or more rows in the "open file table". Imagine we only have these three file descriptors. Then how does the "open file table" look like?

Usually all three file descriptors point to the same file, but that doesn't mean they point to the same entry in the "open file table". So how the open file table looks like?

_ | offset | reference count | permissions | flags | pointers
_ |    ?   |        ?        |      ?      |   ?
possible more rows

Open in new window


The lsof command shows for example:

lsof        721    root    0u      CHR              136,1       0t0          4 /dev/pts/1
lsof        721    root    1u      CHR              136,1       0t0          4 /dev/pts/1
lsof        721    root    2u      CHR              136,1       0t0          4 /dev/pts/1

Open in new window


The file "/dev/pts/1" is CHR (character special file). They all point to the same file.
I'm also wondering why it's for example "0u" and not "0r"? The file descriptor 0 stands for input, so it only has to read something.

r for read access;
w for write access;
u for read and write access;

Open in new window


I would expect something like: 0r, 1w, 2w instead of 0u, 1u, 2u? And what are the offsets et cetera?
0
My question is about a pipe/pipeline in Unix. And it's especially about the FD (File descriptor) numbers/integers associated with it.
This is what I would expect:

  PROCESS A           PROCESS B
  0 stdin
  1 stdout -> pipe -> 0 stdin
  2 stderr            1 stdout
                      2 stderr

Open in new window


However, on the internet I'm reading different things.

For example, see: http://pubs.opengroup.org/onlinepubs/009696799/functions/pipe.html


Their integer values shall be the two lowest available at the time of the pipe() call.

Also see the images here: http://www.rozmichelle.com/pipes-forks-dups/#attachment_7362

Why new file descriptors are created? Why they don't use stdout (1) of the parent process? They could just redirect this existing
file descriptor (1/stdout) to the pipe. Do I miss something?
1
Hi Experts

Could you point what must to be done to make a PowerBuilder 6.5 project to be used on PowerBuilder 7.0?

I saw that "workspace"  must to be used but how to make the old  libraries to enter on it...


Thanks in advance!
0
hi,

i have script working.
When it runs it check for files and send email alert if not files and also if has files.
Currently it sending the email alerts text format.
Request experts help, want to send email with htm format.
and for errors it should bold the text and color RED.
can help...


#Requires -version 3.0
$WarningPreference="Continue"
function Send-Mail
{
  param (
    [string] $Email_Subject,
    [string] $Email_Body,
    [string] $Email_Attachment
  )
  Send-MailMessage -SmtpServer 'mailserver.com' `
  -Body $Email_Body `
  -From 'donotreply@mail.com' `
  -To 'admin@mail.com' `
  -Subject $Email_Subject `
  -Attachments $Email_Attachment
}
function Send-Error
{
  Write-Host "Sending Error Alert @ $emaildate"
  $subject = "ACTION REQUIRED : Error Alert @ $emaildate"
  $logcontents = get-content $Logfile | Out-String
  $Body = "Dear All,`n`nThis email sent by system for errors highlighted below."  + $logcontents + "`n Regards,`n Job Process"
  Send-Mail -Email_Subject $subject -Email_Body $Body -Email_Attachment $Logfile }
function send-status
{
  Write-Host "Sending Success Alert @ $emaildate"
  $subject = "INFO : Success Alert @ $emaildate"
  $logcontents = get-content $Logfile | Out-String
  $Body = "Dear All,`n`nThis email sent by system for your information"  + $logcontents + "`n Regards,`n Job Process"
  Send-Mail -Email_Subject $subject -Email_Body $Body -Email_Attachment $Logfile }

  #check if source files exists
0
I've got a job creating the backend for a mobile app for a company. They will need me to do sysadmin tasks as well.

This app is useless if it can't connect to a server. I need to come up with a redundant setup, ideally over different providers (would like to use Linode and AWS).

I was wondering - what is this called, and how do I set it up? The most similar thing I have done is hosting a database on a separate server - both of those were in the same datacenter. I've read that you do not want the database to accept connections from public IP Addresses.

How do I set this up where there is redundancy over multiple data centers?
1
CompTIA Network+
LVL 12
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Constructors are not inherited:
The sub class cannot inherit constructors from its super class. Consider the following example:
1
2
3
4
5
6
7
8
9
10
11
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 
public class Sub extends Super {
 
}
We can create a new instance of Super like this:
1
Super super = new Super(“Hello”);   //OK
But we cannot do the same for the Sub class:
1
Sub sub = new Sub(“Hello”); //Compile error, since constructor is not inherited
The solution is to write a constructor for the sub class and call the super’s constructor, for example:
1
2
3
4
5
6
public class Sub extends Super {
 
    public Sub(String text) {
        super(text);
    }
}

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i wrote as below

package SuperSub;
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 

Open in new window


package SuperSub;
public class Sub extends Super {
	//Super super = new Super(“Hello”);
}

Open in new window


i am getting error in line 2 of Sub class
Implicit super constructor Super() is undefined for default constructor. Must define an explicit constructor
package SuperSub;
public class Sub extends Super {

	public Sub(String text) {
		super(text);
		// TODO Auto-generated constructor stub
	}
	//Super super = new Super(“Hello”);
}

Open in new window

above is fine though not sure why i cannot just have Sub empty class?
Please advise
0
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        this.test();
}

Open in new window

why above code is not working
i see error as below at line 21,15
Syntax error, insert "}" to complete ClassBody

Please advise
0
The super keyword:
In Java, the superkeyword is used to access members of the super type from the sub type. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Super {
    protected void bar() {
        System.out.println("Super.bar()...");
    }
 
}
 
public class Sub extends Super {
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
        super.bar();
        this.bar();
    }
}
Here, we can see that both classes have a method called bar() (overriding). Therefore, if we want to invoke the super’s version of the bar() method, the super keyword is used.
 

Open in new window


super with this example not working for me
package SuperThis;
public class Sub extends Super {
	public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    //public void test() {
       // super.bar();
        //this.bar();
   // }
        
}

Open in new window


above code giving below error
Cannot use super in a static context
Cannot use this in a static context

how to fix this
package SuperThis;

public class Test {
public static void main(String[] args) {
	 Sub sub=new Sub();
	    sub.test();
}
}

Open in new window


Super.bar()...
Sub.bar()...


does it need separate class for this to test
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        test();
}

Open in new window

how to test in same Sub class

above gives error at line 20
Multiple markers at this line
      - This method requires a body instead of a
       semicolon
      - Return type for the method is missing
      - Duplicate method test() in type Sub

please advise
0
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i tried as below

package MultipleInheritance;
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class C extends A, B {
    public void methodC() {
        foo();
    }
}

Open in new window


on C class i get below error

Multiple markers at this line
      - Syntax error on token "extends", delete this token
      - Syntax error, insert "ClassBody" to complete
       ClassDeclaration
      - Syntax error, insert "}" to complete Block

can you please advise what above error means

it did not say "multiple inheritance of state not allowed"

Please advise
0
6. Multiple inheritance of state is not allowed:
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.
 
7. Multiple inheritance of type is allowed:
This means Java does allow multiple inheritance between interfaces. For example:
1
2
3
4
5
6
7
8
9
10
11
public interface X {
    public void methodX();
}
 
public interface Y {
    public void methodY();
}
 
public interface Z extends X, Y {
    public void methodZ();
}
This is allowed because interfaces do not have concrete methods, thus there is no ambiguity.
Likewise, we can have a class implements multiple interfaces:
1
2
3
4
5
6
7
public class Sub implements X, Y, Z {
    public void methodX() { }
 
    public void methodY() { }
 
    public void methodZ() { }
}

Open in new window


if both Interface X and Interface Y has same method called methodAB what happens?



Open in new window

0
Let’s look at the constructor of the Truckclass - it can access the protected field numberOfWheels and the default field name. However, it cannot access the private field age. We can write:
1
2
3
Truck truck = new Truck();
truck.start();
truck.move();
But the Java compiler will complain if we try to invoke the private method test():
1
truck.test();   // COMPILE ERROR, since private member is not inherited

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java


i supposed to put below code in which class Car or Truck or Moveable?


public class Truck extends Car {
    public Truck() {
        numberOfWheels = 8;
        name = "Truck";
        age=10;
    }
    
    Truck truck = new Truck();
    truck.start();
    truck.move();
    
}

Open in new window




or as below

public class Car extends Vehicle {
	String name;
	protected int age;
    //protected int age;
    protected int numberOfWheels = 4;
    
    public void move() {
        System.out.print("Moving by engine...");
    }

	@Override
	public void start() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub
		
	}
	
	/*Truck truck = new Truck();
	truck.start();
	truck.move();*/
}

Open in new window


below i cannot put as it is interface

public interface Moveable {
    public void start();
 
    public void stop();
 
    public void move();
}

Open in new window


please advise
0

System Programming

40K

Solutions

19K

Contributors

Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.