web stats analysis

How to programmatically search for a file inside some JAR into java?

Java: Copy jar files programmatically into another destination.

I have a simple solution is like below:

What is jar file?

Jar is a collection of a multiple files as single one file. Jar files are an better way to distribute java application.It is compressing a file into a zip file is an better way to distribute other program over the internet.

To start JAR file just type the below command.

java -jar example.jar

To explode or extract the JAR file type the below command.

jar -xf example.jar

Now how to search jar files programmatically into another destination?

=>You just use JarInputStream to open it.
=>Then over it using getNextJarEntry.
=>Finaly compare name using ZipEntry.getName().

Your jar file has been search programmatically.

java.lang.NoClassDefFoundError.

 

How to solve java.lang.NoClassDefFoundError?

I try and get simple solution is like below:

Here I explain how to solve this type of error.
Step:1-Check the class path in evironment variables.
Step:2-I opened project in navigator of eclipse and check the class files.

Here my class file are in different folder not in bin folder.

Step:3-Simple I just copied different folder class files to bin folder.
Step:4-Then last copy .class files to bin directory of your eclipse.

My problem is resolved by above solution and hope also your problem will be resolve.

 

How to line break between two lines in MessageBox.Show?

How to insert an enter between lines into a MessageBox.Show?

How to line break using MessageBox.Show?

I have Simple solution is below:

You just add \n between two line.

MessageBox.Show(“Good\nMorning”);

Output like this.

Good
Morning

Your problem has been solved.

How to create a pop-up wordpress email contact form?

To create a pop-up wordpress email contact form.

Create pop-up wordpress email contact form.

If you want to create it then follow below steps:

Step:1-Download Contact Form 7 and the Easy FancyBox plugins.
Step:2-For download Contact Form 7 Click here.
Step:3-For download Easy FancyBox Click here.
Step:4-Install both plugin and active.
Step:5-We will use the example email form already created in Contact Form 7.The Contact Form administration page displays the code you must cut and paste into your WordPress editor to generate the form.
Step:6-Create a new page in wordpress.include email form.
Step:7-Then you have to paste the code contained in brackets from the contact form 7 administration page into your page.
Step:8-You paste the code where you want to appears like click below.
Now your wordpress form display on a page in your site.Now,instead of being embedded in the page,if you want it to pop-up and overlay the page when a visitor clicks a link.That is where the Easy FancyBox plugin comes in.You can make any page element appear in a pop-up window with Easy FancyBox.Edit new page, click the HTML tab, and add the following code.


<a href="#contact_form_pop">Contact Us</a>

<div style="display:none">
<div id="contact_form_pop">
<?php echo do_shortcode(' [contact-form 1 "Contact form 1"] '); ?>
</div>
</div>
Now have a link that launches your WordPress form in a pop-up window.You will probably want to do some CSS styling of the email form to ensure that the height and width are correct and that error messages are contain within the pop-up, but this should be enough to get you started.

How to copy local text file to remote desktop?

Copy local text file to remote desktop.

You just impliment below code.



ExecuteCommand("Copy " & Directory.GetCurrentDirectory & "\Output\Files.txt \\myservername\C$\Files.txt")

' ...

Public Sub ExecuteCommand(ByVal Command As String)
Dim ProcessInfo As ProcessStartInfo
Dim Process As Process
ProcessInfo = New ProcessStartInfo("cmd.exe", "/K " & Command)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = True
Process = Process.Start(ProcessInfo)
' You might want to wait for the copy operation to actually finish.
Process.WaitForExit()
' You might want to check the success of the operation looking at
' Process.ExitCode, which should be 0 when all is good (in this case).
Process.Dispose()
End Sub

Finally, you could have just used File.Copy instead

File.Copy(Directory.GetCurrentDirectory & “\Output\Files.txt”,
“\\myservername\C$\Files.txt”)

How to use Module Pattern in javascript?

Module Pattern in javascript.

Description of javascript module pattern

Modules are an integral part of any robust application’s architecture and typically help in keeping the units of code for a project both cleanly separated and organized. The module pattern is a common JavaScript coding pattern.If you want to understand Module Pattern you should have knowledge about the Closure principle of JavaScript.

Description about closure:

Closures are define through which inner functions can refer to variables present in their outer enclosing function after their parent functions have already terminated.

Here example for closure:


// Below function generates a new function for adding numbers

function generate(number) {

// Return a simple function for adding two numbers

// with the first number borrowed from the generator

return function (toAdd) {

return number + toAdd
};
}

// addFive now contains a function that takes one argument,

// adds five to it, and returns the resulting number

var five_add = generate(5);

// We can see here that the result of the six_add function is 9,

// when passed an argument of 4

alert(five_add(4) == 9);   // Which return true

Example of Module Pattern


var Module_Employee = (function () {
var List_employee = [];
return {
add: function (employee) {
List_employee.push(employee);
},
getAll: function () {
return List_employee;
},
Count: function () {
return List_employee.length;
}
};
})();
We can use our Module_Employee in below way.

Module_Employee.add({ Id: '01', Name: 'Emon Khan', Designation: 'Software Engineer' });
Module_Employee.add({ Id: '02', Name:'Khairul Islam', Designation: 'Senior Software Engineer'});
Module_Employee.getAll();

We could not complete your iTunes Store request. An unknown error occurred (-9808).

Error:We could not complete your iTunes Store request. An unknown error occurred (-9808). There was an error in the iTunes Store. Please try again later.”

iTunes Store: “An unknown error occurred (-9808)”

Apple iTunes Results for “Not complete store request”

I try and get solution is like below:

When you try to connect to the iTunes Store you may receive the alert message “We could not complete your iTunes Store request. An unknown error occurred (-9808). There was an error in the iTunes Store. Please try again later.”

Follow below steps:

Step:1-Go to start -> control panel -> internet option.

Note:-If you are using Windows Vista you may need to select Classic View on the left before you
can see Internet Options.
Note:-If you are using WIndows 7 you may need to change “View by” to either Large icons or
Small icons before you can see Internet Options.
Step:2-Click the Advanced tab.
Step:3-In the Settings box, scroll down to the Security section.
It’s like a below.

Step:4-Deselect the option to “Check for server certificate revocation (requires restart).”
Step:5-Select the options for “SSL 3.0″ and “TLS 1.0.”.
Step:6-Apply the changes and restart your computer.

String was not recognized as a valid DateTime.

String was not recognized as a valid DateTime

Follow below solution:

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax:


public static DateTime ParseExact(
string str,
string format,
IFormatProvider provider
)
str

=> contain date and time to convert.
format => It is specify that define the required format of str.

provider

=> It is a object that supplies culture-specific format information about str.

Exceptions

Exception Condition
ArgumentNullException str or format is null.
FormatException str or format is an empty string.
-or-
str does not contain a date and time that corresponds to the pattern specified in format.
-or-
The hour component and the AM/PM designator in str do not agree.

Demo of ParseExact method


using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      string String, format;
      DateTime result;
      CultureInfo provider = CultureInfo.InvariantCulture;

      // Parse date-only value with invariant culture.
      String = "06/15/2008";
      format = "d";
      try {
         result = DateTime.ParseExact(dateString, format, provider);
         Console.WriteLine("{0} converts to {1}.", dateString, result.ToString());
      }
      catch (FormatException) {
         Console.WriteLine("{0} is not in the correct format.", String);
      } 

      // Parse date-only value without leading zero in month using "d" format.
      // Should throw a FormatException because standard short date pattern of
      // invariant culture requires two-digit month.

      String = "6/15/2008";
      try {
         result = DateTime.ParseExact(dateString, format, provider);
         Console.WriteLine("{0} converts to {1}.", String, result.ToString());
      }
      catch (FormatException) {
         Console.WriteLine("{0} is not in the correct format.", String);
      }

      // Parse date and time with custom specifier.

      String = "Sun 15 Jun 2008 8:30 AM -06:00";
      format = "ddd dd MMM yyyy h:mm tt zzz";
      try {
         result = DateTime.ParseExact(dateString, format, provider);
         Console.WriteLine("{0} converts to {1}.", String, result.ToString());
      }
      catch (FormatException) {
         Console.WriteLine("{0} is not in the correct format.", String);
      }

      // Parse date and time with offset but without offset's minutes.
      // Should throw a FormatException because "zzz" specifier requires leading
      // zero in hours.

      String = "Sun 15 Jun 2008 8:30 AM -06";
      try {
         result = DateTime.ParseExact(String, format, provider);
         Console.WriteLine("{0} converts to {1}.", String, result.ToString());
      }
      catch (FormatException) {
         Console.WriteLine("{0} is not in the correct format.", String);
      } 

      String = "15/06/2008 08:30";
      format = "g";
      provider = new CultureInfo("fr-FR");
      try {
         result = DateTime.ParseExact(String, format, provider);
         Console.WriteLine("{0} converts to {1}.", String, result.ToString());
      }
      catch (FormatException) {
         Console.WriteLine("{0} is not in the correct format.", String);
      }
   }
}

// The example displays the following output:
//       06/15/2008 converts to 6/15/2008 12:00:00 AM.
//       6/15/2008 is not in the correct format.
//       Sun 15 Jun 2008 8:30 AM -06:00 converts to 6/15/2008 7:30:00 AM.
//       Sun 15 Jun 2008 8:30 AM -06 is not in the correct format.
//       15/06/2008 08:30 converts to 6/15/2008 8:30:00 AM.

How to add android date time picker?

Android Date Time Picker Dialog.

Add the following namespace.

->Android additionally supports widgets such as DatePicker, TimePicker as well as dialogs just like DatePickerDialog, TimePickerDialog for helping users enter dates and times.
->The DatePicker and also DatePickerDialog are same it’s enable you to set the starting date for selection, in the form of a year, month, and day of month value.
->Both are give a callback object OnDateChangedListener or even OnDateSetListener where you are informed of a new date selected from the user.
->You are able to store that date somewhere because there is no some other way for you to get at the chosen date later on.
->To Test this Date and Time Picker widget, create an android project and place two buttons.One for set the date and another one for set the time. And display the end result in a textview.

Demo example of Date Time picker is like below:

Creating Layout for Date Time Picker Widget


main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/timeTxt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/time_text" />
    <Button
        android:id="@+id/dateBtn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/set_date"
        android:onClick="chooseDate"
        />
    <Button
        android:id="@+id/timeBtn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/set_time"
        android:onClick="chooseTime"
        />
</LinearLayout>

Java code to configure the Date Time Picker Widget:


AndroidDateTimePickerActivity.java

package com.vimaltuts.android.androiddatetimepicker;
import java.util.Calendar;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import java.text.DateFormat;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
public class AndroidDateTimePickerActivity extends Activity {
private Button timeBtn;
private Button dateBtn;
DateFormat formatDateTime=DateFormat.getDateTimeInstance();
Calendar dateTime=Calendar.getInstance();
private TextView timeLabel;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
timeLabel=(TextView)findViewById(R.id.timeTxt);
updateLabel();
}
public void chooseDate(){
new DatePickerDialog(AndroidDateTimePickerActivity.this, d, dateTime.get(Calendar.YEAR),dateTime.get(Calendar.MONTH), dateTime.get(Calendar.DAY_OF_MONTH)).show();
}
public void chooseTime(){
new TimePickerDialog(AndroidDateTimePickerActivity.this, t, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE), true).show();
}
DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,int dayOfMonth) {
dateTime.set(Calendar.YEAR,year);
dateTime.set(Calendar.MONTH, monthOfYear);
dateTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
}
};
TimePickerDialog.OnTimeSetListener t=new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
dateTime.set(Calendar.MINUTE,minute);
updateLabel();
}
};
private void updateLabel() {
timeLabel.setText(formatDateTime.format(dateTime.getTime()));
}
}
->In the button property we allocated a related method to each button that should be called when the user clicks it.
->For the DatePickerDialog, we give it a OnDateSetListener callback that updates the Calendar with the new date.
->For the TimePickerDialog, it gets a OnTimeSetListener callback to update the time part of the Calendar.

For more detail Click here..

The type or namespace name ‘NameValueCollection’ could not be found(are you missing a using directive or an assembly reference?)

Solution of The type or namespace name ‘NameValueCollection’ could not be found(are you missing a using directive or an assembly reference?)

Add the following namespace.

using System.Collections.Specialized;