Currently Browsing
Programming
About Unicode
- 22 February //
- Posted in Computer, Internet, Programming, windows //
- Tags : java, language, programming, python, unicode
- No Comment
Unicode is a system designed to represent every character from every language.
Unicode represents each letter, character, or ideograph as a 4-byte number.
I just want to explain what is UTF-32,UTF-16, UTF-8
The unicode that uses four bytes per character, which is nothing but 32 bits = 4 bytes.
There is another unicoding which is UTF-16 which takes 2bytes.
UTF-8 is a variable-length encoding system for Unicode.
Exception in thread “main” java.lang.NoSuchMethodError: main
- 4 January //
- Posted in Free Stuff, Programming //
- Tags : application, example, exception, java, main, program, two classes
- 1 Comment
When these kind of exception occurs?
These type of exception occur only when the name of the class is different from the given name.
Explanation:
Let us think we have created two classes in the same file.
for example Login class and LoginDemo class
In Login class we have just given the methods, which are used for performing some actions and LoginDemo has main method in it.
If we have given the file name as Login not LoginDemo then there will be no problem in compilation.
Since compiler can compile any type of java with proper syntax, now the file cannot be executed it gives the error
Exception in thread “main” java.lang.NoSuchMethodError: main
During the execution , java looks for main method inside the class name Login but it cannot find the main method.Hence it says cannot find the main method.
If you want to run this means you have two ways.
1.Change the name of the file two the name with class consisting of main method.
2.You can even run the class without changing the name of the method by just giving the class name consisting main method.
ex java Login
Exception in thread “main” java.lang.NoSuchMethodError: main
//main method is not available here
java LoginDemo
It will run fine because java looks for main method in the class LoginDemo with file name Login.
Example for desktop java application.
- 4 January //
- Posted in Computer, Programming, windows //
- Tags : application, clock, desktop application, digital clock, java, program, simple java program, swing application
- 1 Comment
We can create a desktop java application.
Here I am going to give an example and explain how a desktop java application works on any environment.
Let us create a java program..
DigitalClock.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
public class DigitalClock extends JFrame implements ActionListener {
JLabel l1 = new JLabel();
Timer t;
public DigitalClock() {
super("Digital Clock");
l1.setFont( new Font("Verdana",Font.BOLD,30) );
l1.setHorizontalAlignment( JLabel.CENTER);
t = new Timer(1000,this);
t.start();
getContentPane().add(l1);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setSize(200,200);
setVisible(true);
// call actionPerformed to get Time at the startup
actionPerformed(null);
}
public void actionPerformed(ActionEvent evt) {
l1.setText( new Date().toString().substring(11,19));
}
public static void main(String args[]) {
new DigitalClock();
}
}
So now follow these steps to create desktop application for this swing application
1. Create a manifest file called digitalclock.mf as follows.digitalclock.mf
Manifest-Version: 1.0
Main-Class: DigitalClock
2. Create digitalclock.jar file using JAR utility provide by JDK. Jar file is associated with manifest file digitalclock.mf and program DigitalClock.class.Run this command in command prompt
jar cfm digitalclock.jar digitalclock.mf DigitalClock.class3. After digitalclock.jar is created, you can invoke
main class (DigitalClock.class) by running digitalclock.jar as follows.Run this command in command promptjava -jar digitalclock.jarDon't forget to place all the files in the same folder.
But our aim is to run this file from a shortcut on desktop. So follow the steps to create a desktop shortcut as follows:
- Right click on Desktop
- Select New->ShortCut option from the popup menu
- Using Browse button select digitalclock.jar file
- Click on Next button
- Enter Clock as the name for shortcut.
- Click on Finish
Once shortcut is created on the desktop, just double click on the shortcut to run DigitalClock.class.
How to add strings to present table in MySql database?
- 3 January //
- Posted in Computer, Programming //
- Tags : concat to given string, concatination, db, Music, strings
- No Comment
We can add strings to fields present in mysql database.
The below given statement will help you how to add strings to values to mysql database:
Motion chart.
- 2 January //
- Posted in Programming, Uncategorized //
- Tags : bar chart, density chart, free chart, google visualizatiion, motion chart
- 1 Comment
Well I am here going to explain only what is motion chart and where you can find it for free.Motion chart is one of the most advanced chart mechanism used.
A single chart consist of three charts in it,it has a bar chart,annotated time line chart and density chart.It will show in a single chart.So if a person looking for representing the three chart, he can use this kind of chart.The google has provided it for free.So you can use this chart in any of the web pages and development purpose.
Free graphs.
- 2 January //
- Posted in Programming //
- Tags : free chart, google visuali
- No Comment
If you want to find free graphs then you should go for google visualization which is the for free.We can directly implement in any of the web pages and for development also.We can implement Google visualization by using gvis api. It is compatable for any language and there is another advantage,where you can try gvis directly.
How to print double quotes (“) in java?
- 2 January //
- Posted in Programming //
- Tags : java program with colons, simple java program
- No Comment
These symbols cannot be printed directly in java.
So here is the procedure to print quotation marks while printing.
Here is a small example
import java.io.*;
class Exclam
{
public static void main(String args[])
{
System.out.println(“\”hi Exclam \”");
}
}
So if you want to print any special characters in print statement, before it must contain a slash(\).Which will tell the compiler to exclude the next character and directly print in the command prompt.
How to create a Desktop Java application?
- 7 December //
- Posted in Programming //
- Tags : application, class, desktop, jar, java, jvm, name.mf, progam
- 1 Comment
We can create a desktop java application.
First create Manifest file
Manifest-Version: 1.0
Main-Class:”Give name of the the class here”
Save this application as name.mf.
Create a jar file using JAR utility provided by JDK.
In the jar file the .class files and Manifest file should be there.
After creating .jar file now open the .jar file using the select application using jvm.Now you can keep any where in youre drives and just give the shortcut to the jar file on Desktop.
If you looking for an example.look into this link
multiple Ant to Maven
- 22 October //
- Posted in Programming //
- Tags : Ant, Ant to Maven, authentication, plugin execution, Tomcat
- No Comment
It is of course possible to use several snippets in Ant to Maven. This one adds the Ant plugin execution in a number of executions a day. Important point here is to use the ID tags.
…
Unfortunately, you can use for the ID tag is no simple notation such as:
…
That would in my view clearer and space saving. But it does not work.
The Realm is only one element in the authentication with Tomcat. The weiterne Devices (login-config, roles and security constraints) are in the web.xml file containing the project.
JDBC Realm in Tomcat
- 22 October //
- Posted in Programming //
- Tags : JDBC Realm, login-config, org.apache.catalina.realm.JDBCRealm, Tomcat, webapp
- No Comment
Using the JDBC Realm in Tomcat you can perform very simple and elegant user authentication and access control, or have them carried out by Tomcat. For this we must add the file in the webapp context.xml the following section:
connectionURL = "jdbc: mysql: / / localhost: 3306/test"
Connection name = "smartBLU"
connection Password = ""
Table user = "USER"
usernamecol = "Login Name"
userCredCol = "password"
userRoleTable = "USER_ROLE"
roleNameCol = "role_name"
digest = "sha" />
Tomcat will then attempt to authenticate the user against a database jdbc: mysql: / / localhost: 3306/test with the appropriate parameters. The database table here called USER. The user passwords are hashed with SHA. SHA means in the Java world as I know, SHA2.
In this example we used is not the normal JDBC realm but a separate realm that was derived from the JDBC realm, but also a migration function (the old system used but not SHA Crypt) holds. The jar file which contains this related class must be available for Tocat, they must therefore in the directory tomcat / libs are. Alternatively, you can be entered in this example, the JDBC realm (org.apache.catalina.realm.JDBCRealm).
The Realm is only one element in the authentication with Tomcat. The weiterne Devices (login-config, roles and security constraints) are in the web.xml file containing the project.