Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

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

Sign up to Post

Avoid Empty Catch Blocks
It’s a very bad habit to leave catch blocks empty, as when the exception is caught by the empty catch block, the program fails in silence, which makes debugging harder. Consider the following program which calculates sum of two numbers from command-line arguments:
public class Sum {
    public static void main(String[] args) {
        int a = 0;
        int b = 0;
        try {
            a = Integer.parseInt(args[0]);
            b = Integer.parseInt(args[1]);
        } catch (NumberFormatException ex) {
        int sum = a + b;
        System.out.println("Sum = " + sum);
Note that the catch block is empty. If we run this program by the following command line:
java Sum 123 456y
It will fail silently:
Sum = 123

Open in new window

when i tried above example i am getting different error as below istead of getting 123

public class Sum {
    public static void main(String[] args) {
        int a = 0;
        int b = 0;
        try {
            a = Integer.parseInt(args[0]);
            b = Integer.parseInt(args[1]);
        } catch (NumberFormatException ex) {
        int sum = a + b;
        System.out.println("Sum = " + sum);

Open in new window

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Sum.main(

even below good catch block example also gives same error
public class SumFixed {
    public static void main(String[] args) {
        int a = 0;
        int b = 0;
        try {
            a = Integer.parseInt(args[0]);
            b = Integer.parseInt(args[1]);
        } catch (NumberFormatException ex) {
            System.out.println("One of the arguments are not number." +
                               "Program exits.");
        int sum = a + b;
        System.out.println("Sum = " + sum);

Open in new window

Please advise
Become a Microsoft Certified Solutions Expert
LVL 12
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

I need help with creating an array from a Select Query of my data table and then reading those array items into a combobox.

My code below just gives me the number of distinct items in the BulkSaleNumber column of my tblAssetData Table, but it doesn't give me the array items so that I can use them to populate my combobox.

Your help will be greatly appreciated in directing me in the right direction in creating an array from a query and then populating a combobox with the array  items.

        Dim myArray(0) As String
        Dim i As Integer
        Dim myReader As OleDbDataReader

        cmd.CommandType = CommandType.Text
        cmd.CommandText = "SELECT DISTINCT BulkSaleNumber FROM tblAssetData"
        myReader = cmd.ExecuteReader()
        Do While myReader.Read()
            myArray(i) = myReader!BulkSaleNumber
            ReDim Preserve myArray(UBound(myArray) + 1)
            i += 1

Open in new window

thanks for the compliment s from experts exchange that is the my second question what is the write way to play and browse a file that can be downloaded from java in the following format like jpj,PNG,text,docx,xisx,PDF and question is that what is a java and what is the process to run java and java script in any mobile number and can I have to run in any mobile device through any of the email I'd.  solution this question in any way that is possible. and one thing is that ican play movies and videos  through java script was this any of the way you would have to like to suggest me immediately. thank you again experts team.
Hi Experts,

     I had build and run a docker image like this.

docker build -t harvest-trove:1.0.3 .
docker run --name trove_pull ${trove_environment[@]} -d -restart always harvest-trove:1.0.3 start pull                 

Open in new window

I want to use docker compose for the above two commands

I had created the docker compose like this.

      build: .
      image: harvest-trove:1.0.3
                -  .:/home/trove
        -  web-variables.env
            command: python3 migrate
    image: harvest-trove
       - web-variables.env
         - harvest-trove
       command: harvest-trove:1.0.3 start pull

Open in new window

when I run docker-compose up I get the following error.

error with docker-compose up
Please help me in fixing this issue.

With Many thanks,
Bharath AK
I am trying to learn how to program navigation of a  Windows Folder using Explorer.

As a test project, I want to use the IWebBrowser2 object to select a specific file in a previously opened folder.

In other words, I want it to be similar to the DOS command line  < explorer /select,"C:\aatmpK\test.xlsm" >
the following code comes close, but the .navigate command is not exactly right.

An Excel vba solution would be ideal, but any solution that uses the IWebBrowser object would be OK.

can anybody help?
Sub test 

Dim FolderPath, FullPath, PathOpen
FolderPath = "C:\aatmpK"
FullPath = "c:\aatmpk\test.xlsm"

Dim WasFound As Boolean, i As Long, ExplorerNoDups As String
Dim wndw As Object

  With CreateObject("shell.application")
    For Each wndw In .Windows
     On Error Resume Next
        Dim IsFolder As Boolean
        IsFolder = False
        IsFolder = TypeName(wndw.document) Like "IShellFolderViewDual*"
     On Error GoTo 0
     If IsFolder Then
        If Not TypeName(wndw) Like "IWebBrowser*" Then Stop
        PathOpen = Replace(wndw.document.Folder.Self.path, "s:", "myserver\myshare", 1, 1, 1)
        If LCase(FolderPath) = LCase(PathOpen) Then
             wndw.navigate FullPath  ' < this does not seem to do what I want
             WasFound = True
             Exit For
        End If
        ExplorerNoDups = ExplorerNoDups & "<" & PathOpen & ">"
     End If
    If WasFound = False Then MsgBox "Folder 

Open in new window

I need to monitor the changes of approximately 10 files in 4 folders and sub-folders in such a way that it makes it very easy to tell what's changed from a development perspective. All files are readable with notepad.

Assistance is greatly appreciated.
I use a Userform to setup an AutoFilter
How can I use the special cells, visible after the Auto Filter?
Obviously the attached code will refer to all data in the worksheet.
Can I adapt it so that it just focuses on special visible cells?

Dim LastRowA As Long, x as integer

With Sheets("Sheet1")
LastRowA = .Cells(.Rows.Count, "D").End(xlUp).Row
End With

For x = 1 To LastRowA
If Range("A" & x).value = 125 Then
'insert code here
End If

Next x

Open in new window

I have had a few people tell me that when trying to visit a site using safari on their iPhones, they get an error that says:

Safari cannot open the page because the server cannot be found.

I asked other people to test on their iPhones and they said it works fine. After asking Google about this it seems that the answer is always something to do with the phone itself. But, it is not realistic to ask everyone with an iPhone to check this setting, and check that setting in order to try use the website.

Does anyone have any suggestions regarding this?
I am working with matcher and pattern in Java. I think this test code should work to add and print my desired search but it is not. If anyone can take a look and fix this it would be much appreciated. Note the if I just use the while loop it works fine. It is when I add in the for loop to iterate through the array list is when it prints out blank.

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test {

    public static void main(String[] args) {

        ArrayList<String> linet = new ArrayList<>();
        ArrayList<String> lines = new ArrayList<>();

        lines.add("O#833452-14943408 PO#Subject: Re: gg  - Oops. Your O#purchase order is missing key payment information.PPO O#769117789:C11134 [ ref:_00D30dWxY._5001311TVgB:ref ]");
        lines.add("SO#833452-14943408 PO#Subject: Re: gg  - Oops. Your O#purchase order is missing key payment information.PPO O#769165189:C11134 [ ref:_00D30dWxY._5001311TVgB:ref ]");
        lines.add("O#833452-14943408 PO#Subject: Re: gg  - Oops. Your O#purchase order is missing key payment information.PPO SO#7696561189:C11134 [ ref:_00D30dWxY._5001311TVgB:ref ]");
        lines.add("CASE-1443453931800\tPN#109684324201-2 qty1EA\t\"");

        for (int i = 0; i < lines.size(); i++) {

            String line = lines.get(i);

            String so1 = "SO#";
            Pattern p = Pattern.compile(so1);
            Matcher m = …
I have a working python script that scrapes tables. After the data is copied to an Excel file I would like to remove this particular value - '--' from all sheets in the Excel file and replaced with a zero value - '0'.
Whats the best way to do this using python?

import urllib.request
import pandas as pd
import sys
import os
#import xlsxwriter
import openpyxl

sys.path.append('/Users/bhav\ 1/Documents/keepbak2/python')

#xlfile = 'countrydiedtest.xlsx'
xlfile = "/Users/bhav 1/Documents/dump/countrydiedtest.xlsx"

from html_table_parser import HTMLTableParser

Income = ''
Balance = ''
Cash = ''
Historical = ''

#get website config Income
reqIncome = urllib.request.Request(url=Income)
fIncome = urllib.request.urlopen(reqIncome)
xhtmlIncome ='utf-8')

#get website config Cash
reqCash = urllib.request.Request(url=Cash)
fCash = urllib.request.urlopen(reqCash)
xhtmlCash ='utf-8')

#get website config Balance
reqBalance = urllib.request.Request(url=Balance)
fBalance = urllib.request.urlopen(reqBalance)
xhtmlBalance ='utf-8')

#get website config Historical
reqHistorical = 

Open in new window

Determine the Perfect Price for Your IT Services
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Hello, Experts!

I am needing help with figuring something out.

I have a python script that reads a directory and gives me the last modified date. However, the output is not what I am looking for.

I get the time to be 24-hour format as opposed to US standard 12-hour format. What modifications do I need to make?

import os.path, time
print("Last modified: %s" % time.ctime(os.path.getmtime("test.txt")))
print("Created: %s" % time.ctime(os.path.getctime("test.txt")))

Open in new window

Hello, Experts,

I need help modifying a quick script.

I am working on a powershell script that will query a directory and store a filtered file w/ extension into a variable.

get-childitem $path -recurse -exclude *.mdb

Open in new window

In the directory, there will be multiple .mdbs, but, the mdb I am looking for and want to get with powershell is 9 characters long  or XXXX.mdb.

Could you help me modify the code so that I can figure this out?
I need to open 5 browser windows and position them on the screen so they don't overlap.  I'm envisioning them not having the full frame - don't want the tabs atlong the top, don't want the address bar, etc.  Just a thin frame around the windows (which will be video cameras from Nest).  Each has a unique URL

Anyone know of a script / powershell / something else that will allow that?  Click on it and it opens the windows, sized, placed correctly and in bare bones frames?

I can drop in the correct URL to a script.  The URLs would look like:

The machine would also be used for general surfing, so setting home pages isn't really the best answer (if that's even an answer)

I am using Visual Studio 2017, programming in VB.NET.
I have a reference in my project to DocumentFormat.OpenXml (SDK2.5, Version 2.5.5631.0, Runtime Version 4.0.30319)

At the start of the module, I have the following:
Imports DocumentFormat.OpenXml
Imports DocumentFormat.OpenXml.Packaging
Imports DocumentFormat.OpenXml.Spreadsheet

My code (plagiarized from Google) is as follows:
 Public Function CreateWorkbook(fileName As String) As SpreadsheetDocument
    Dim spreadSheet As SpreadsheetDocument = Nothing
    Dim sharedStringTablePart As SharedStringTablePart
    Dim workbookStylesPart As WorkbookStylesPart

      ' Create the Excel workbook
      spreadSheet = New SpreadsheetDocument.Create(fileName, SpreadsheetDocumentType.Workbook, False)

      ' Create the parts and the corresponding objects
      ' Workbook
      spreadSheet.WorkbookPart.Workbook = New Workbook()

      ' Shared string table
      sharedStringTablePart = spreadSheet.WorkbookPart.AddNewPart(Of SharedStringTablePart)()
      sharedStringTablePart.SharedStringTable = New SharedStringTable()

      ' Sheets collection
      spreadSheet.WorkbookPart.Workbook.Sheets = New DocumentFormat.OpenXml.Spreadsheet.Sheets()

      ' Stylesheet
      workbookStylesPart = …
I've started a python script to scrape a table from a website and print to console, but I'm having trouble displaying the content in the table format as displayed on the website. I'd appreciate some help with the information formatting and getting information from individual cells to be used for calculations.

import os
import os.path
import requests
from bs4 import BeautifulSoup
url = ''
headers= {'User-Agent': 'Mozzilla/5.0'}
response = requests.get(url, headers = headers)
soup = BeautifulSoup(response.content, 'html.parser')
stat_table =soup.find_all('table', class_ ='factsheet-table responsive')
stat_table = stat_table[0]

for row in stat_table.find_all('tr'):
	for cell in row.find_all('td'):

Open in new window

How can I edit two or three files in Github Enterprise and put them all into one pull request?
Hello, I plan to make my youtube online class for programming. Would you please recommend me your best FREE screen recording software for windows 10? Thanks+

How do you create an executable file to open a non-executable file?

I just began using a Corsair K95 RGB keyboard (which includes 18 programmable G-keys) along with its software (CorsairUtilityEngineSetup_2.24.50_release). While assigning macros to the G-keys, I discovered that while the software does allow you to run an executable file (*.exe *.bat *.cmd), there is no option to open a simple non-executable file (eg .txt, .xls, .ahk, .png, etc).

That seemed a bit odd to me but it was confirmed by Corsair tech support so during the conversation I asked about possible workarounds and the response was that I could create an .exe or .cmd file to open the desired non-executable file.

So for example, suppose you want to open the following Excel file:


How would you create an .exe or .cmd file to do that?

How add a functionality of zoom in and out on picturebox in (desktop).
Code for adding image to picturebox
 Protected Friend Sub ScaleImage(ByVal p As PictureBox, ByVal i As Bitmap)
            p.SizeMode = PictureBoxSizeMode.AutoSize
            p.Image = i

            FrmMain.Panel1.AutoScroll = True

        Catch ex As Exception
        End Try

    End Sub

Open in new window

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.

I have a class as below
public class Group
       Prop1 {get; set;}
       Prop2 {get; set;}
       Prop3 {get; set;}
       Prop4 {get; set;}
       int NestingLevel {get; set;}
       List<Group> children {get; set;}

Open in new window

I have built a recursion program to collect a List of Group objects which can then have a variable number of nested children.

A rough idea of what the object tree can look like:
Group 1 (0 depth 0 spacing)
                Group 1.1 (1 depth)
                Group 1.2 (1 depth)
                Group 1.3 (1 depth)
                                Group 1.3.1 (2 depth)
                                Group 1.3.2 (2 depth)
                Group 1.4 (1 depth)
                Group 1.5 (1 depth)
                                Group 1.5.1 (2 depth)
                                Group 1.5.2 (2 depth)

What I need to be able to do is to identify the depth of each level of nesting and set the depth as the value of the NestingLevel property and also for each Top-Level group, to identify the max depth. Can anyone suggest an approach for this? I can't seem to get my head on straight about this.

What's most important for me is to be able to identify the max depth for the top level groups
The path below is where I need to sync to:
This PC\SM-N920V-TheNote5\Phone\Documents

Open in new window

I need an automated way to sync files to a "Portable Media Player" connected to a Windows 10 PC.

The "Portable Media Player" is actually as Samsung Galaxy Note 5: an Android device.

Drag and drop works just fine, but I need to truly automate the process.

I can use VBA built in to MS Access, VB script or even a good fashioned batch file.

NOTE: I use SyncBack to synchronize some folders on my system, but it will not recognize the path to the Note5.

i saw above kind of lines of code in junits

what is java() means

is it new in java 8 which i never heard of?

please advise
#Requires -version 3.0
$ScriptPath = $(Split-Path -Parent $MyInvocation.MyCommand.Definition)
#Log Timestamp
$logdate=Get-Date -Format ddMMyyyy_HHmmss
$Logfile = "E:\Logs\FileProcessing_$logdate.txt"
function LogWrite ([string]$logstring)
   Add-content $Logfile -value $logstring
#Zip Files and move to backup folder

I am want to build script which will do housekeeping of logs, archive folder and log activity if any file deleted then mention the file name deleted and similaly if log file deleted then log it what files deleted.
if no files to delete for day then mention in the log file no files to delete.
Backup folder archive data should have 7 years, more then 7 years should do rotation (older files to delete and new files to keep).
Backup folder 7 years files to keep, after that older archive files to delete and newer archive file to keep it.
Log folder 1 years logs to keep, after that older log files to delete and newer log file to keep it.
what are differences between eclipse short cuts F3 and Control +Shift+G
when to use which one?

Please advise
Im getting started to learn VB.NET and ASP.  I am coming from a background with some experience in VB6.  

What software tools do I need in order to develop a webpage with VB.NET and ASP?  Do I need a specific web server from Microsoft?  If so, what version?  Do I need Visual Studio?  If so, what version.  What is needed to begin setting up ASP?  Is that automatically built-in to the web server?

Also, what is the difference between ASP and, if any?







Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.