Posts

Image
Introduction Python in Eclipse IDE - Pydev Plugin PyDev eclipse plugin is popular to enable Eclipse IDE to work with Python. Though there are other dedicated Linux IDE’s available in the market for python but if you specifically want to tweak your Eclipse IDE to make it perfect for Python development then you are at right place. Checkout below video for a step by step guide for PyDev installation in Eclipse IDE Prerequisite:  We assume that you have already installed below softwares. I have also mentioned the versions used in this tutorial against each of these:  1. Python - 3.8.0 2. Java - openjdk 11.0.11 (it is required for Eclipse to work) 3. Eclipse Installed - 2021-06 (4.20.0) 4. Ubuntu - 18.0.4 Steps :  1. Open Eclipse Market Place 2. Search for Pydev plugin In the search box, type 'PyDev' and click on go. 3. Install PyDev Look for the PyDev plugin from the search results and click on install button to install it. PyDev will ask you to select the pac...

Linux CAT command

Image
Introduction CAT Command 'cat' command concatenate files to the Standard Output. The name of this command is derived from 'concatenate' function it performes. It is very popular in Linux/Unix Operating Systems to read input stream/file and prints to Standard output stream. Cat comes with really helpful options/switches to get the desired output. Checkout video below for CAT command's basic usage with examples: CAT Options and usage Create a new file Creating a new file using CAT is simple. Let's say we want to create a new file with name foo.txt. Just use below command in terminal. cat > foo.txt Above command uses '>'(greater than) symbol to tell the system that we are going to create new file. Cat will ask for the input content of the files. Write content for the file and press Ctrl+d. foo.txt will be created with the content provided. ...

How to Load Servlet on StartUp and Call a Method using Java in NetBeansIDE

Image
How to Load Servlet on StartUp and Call a Method using Java in NetBeansIDE How to Load Servlet on StartUp and Call a Method using Java in NetBeansIDE 1. Open NetBeansIDE. 2. Create a Java Web Project. 3. Create a Servlet (say StartupServlet). 4. Create a Class(say Message) and write method to call say void display() { System.out.print("-------Hello--------"); } 5. In StartupServlet override init() method of GenericServlet and write code calling display() Method in. 6. Change web.xml. Add this line in web.xml <load-on-startup>0</load-on-startup> 7. Run your project. 8. Finish. Thank You :)

How to upload file using Servlet of Java in NetBeansIDE

Image
How to upload file using Servlet of Java in NetBeansIDE How to upload file using Servlet of Java in NetBeansIDE 1. Open NetBeansIDE. 2. Make a new Java web project. 3. Make a form in index.jsp (method='POST', enctype='multipart/form-data'). 4. Make a servlet(FileUploadServlet) in source package folder and add it to deployment    descriptor(web.xml). 5. Copy this process request method code in your servlet. protected void processRequest(HttpServletRequest request,         HttpServletResponse response)         throws ServletException, IOException {     response.setContentType("text/html;charset=UTF-8");     final String path = request.getParameter("destination");     final Part filePart = request.getPart("file");     final String fileName = getFileName(filePart);     OutputStream out = null;     InputStream filecontent = null...

How to use Url-rewriting using Java in NetBeansIDE

Image
URL Rewriting format - (  url?paramName=paramValue   )   1. In your web project make web page (say index.jsp) having a link as:    <a href="FetchDataServlet">Fetch Data from DB...</a> 2. Make a Servlet (say 'FetchDataServlet') and write code to fetch all the record on web         page.         try {                        Class.forName("com.mysql.jdbc.Driver");             Connection con = DriverManager.getConnection("jdbc:mysql://localhost/testdb", "root", "root");             PreparedStatement ps = con.prepareStatement("select * from test2");             ResultSet rs = ps.executeQuery();  ...

How to Detect CapsLock key using Java in NetBeansIDE.

Image
How to Detect CapsLock key using Java in NetBeansIDE. Note: packages and classes used: - java.awt.Toolkit; - java.awt.event.KeyEvent; 1. Open NetBeansIDE. 2. Make a new project say DemoCaps. 3. Make a new JFrame Form in it say CapsLockDetect and design it. 4. RC on Form and Goto Properties~Events~KeyPressed~Select formKeyPressed. 5. Write the following code in the method and Fix all imports:    if(Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK))    {        jLabel.setText("ON");    }    else    {        jLabel.setText("OFF");    } 6. Run the Project. 7. Finish. Thank You :)

How to display record in a table on web page using Servlet, using JAVA in NetBeansIDE

Image
  How to display record in a table on web page using Servlet, using JAVA in NetBeansIDE. 1. Open NetBeansIDE 2. In your project, make a new Servlet (say 'GetDataServlet') 3. In servlet write the code in 'processRequest' method      Code Download : http://www.4shared.com/office/-Z7OvgNO/display_record.html 4. Make a hyperlink in index.jsp with href="GetDataServlet" or as in web.xml 5. Add required JAR in Libraries folder. 6. Run your project. 7. Finish Facebook Page : https://www.facebook.com/pages/Raks/335960303097841 Description:  

How to call private method of a class using Java in NetBeansIDE

Image
Steps: 1. Open NetBeansIDE. 2. In your project make a class file. 3. In your class file make a class, say 'C' with a private method. 4. Make another class say 'Calling' and write the following code in it:     public static void main(String[] args)throws Exception {                 Class c=C.class;         Object obj=c.newInstance();         Method m=c.getDeclaredMethod("msg", null);         m.setAccessible(true);         m.invoke(obj, null);             } 5. Run the file. 6. Finish. Thank You :)

How to take snapshot of screen in Java using NetBeansIDE

Image
How to take snapshot of screen in Java using NetBeansIDE. 1. Open NetBeansIDE. 2. Make a JFrame Form and design it. 3. RC on a button and Goto Events~action~actionPerformed 4. Write following code in it. Note: createScreenCapture(Rectangle rect) method is used to capture screen. It is the method of Robot class. try{ BufferedImage image=new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); ImageIO.write(image,"jpeg",new File(your path)); ImageIcon icon=new ImageIcon(image); jLabel1.setIcon(icon); }catch(Exception e) { e.printStackTrace(); } 5. Run your Project. 6. Finish. Thank You :) Facebook Page

How to get Image from Database(MySQL) in Java with NetBeansIDE.

Image
How to get Image from Database(MySQL) in Java with NetBeansIDE Note: Image is of Blob/LongBlob type in Database. 1. Open NetBeansIDE. 2. In your project make a JFrame form (say NewForm)    2.1 Add a button and a label(to display the image) in it. 3. Right Click on Button and Goto Events~action~actionPerformed    3.1 In actionPerformed method write code for connection.    3.2 Get the image in Byte array. 4. Import mysql connector jar file. 5. Run the JFrame Form file. 6. Finish. Thank You :) Facebook Page

How to insert Image in MySQL Database with Java in NetBeansIDE

Image
How to insert Image in MySQL Database with Java in NetBeansIDE. 1. Open NetBeansIDE 2. Make a new Java Application project. 3. Make a JFrame Form and Design it as in this project. 4. Right Click on 'Choose File' button and Goto events~action~actionPerformed 5. Make a table in your MySQL DB say 'Image' with one Image column of LongBlob type. 6. Enter the code in it(in actionPerformed for Choose File Button).    (Fix all imports)         JFileChooser fc=new JFileChooser();         fc.showOpenDialog(this);         File f=fc.getSelectedFile();         String path=f.getAbsolutePath();         jLabel1.setIcon(new ImageIcon(path));         try{                    ...

How to Perform DES Encryption and Decryption of TXT file in JAVA with NetBeansIDE

Image
1. Open NetBeansIDE. 2. Make a JFrame Form say EncryptTXT.java , I have already made it.               3. Make a class named DESEncrypt.java enter codes and Fix All Imports(It is necessary)     3.1 Write code in it            public static void encrypt(String key, InputStream is, OutputStream os) throws Exception {                                 encryptOrDecrypt(key, Cipher.ENCRYPT_MODE, is, os);                 }                 public static void decrypt(String key, InputStream is, O...

How to make a simple Login page using Servlet & Session in NetBeans IDE

Image
How to make a simple Login page using Servlet & Session in NetBeans IDE 1. Open NetBeans IDE 2. Make a new Project as:    2.1 File~NewProject~Java Web~WebApplication 3. Make a servlet(say First.java) as:    3.1 RightClick on Source Package~New~Other~Web~Servlet    3.2 Name your Servlet    3.3 Check Add Information to deployment descriptor(web.xml file) 4. Make another servlet(say Second.java). 5. Make an HTML file as:    5.1 RC on Web Pages folder and select New~Other~Web~HTML    5.2 Design a simple form in HTML    5.3 Give the url-pattern of First Servlet in the 'action' attribute(say '/First') 6. Write code for First.java to authenticate the user       6.1 In this servlet set the session attribute with a 'key' and its 'value'. 7. Write code for Second.java to view the profile    7.1 In this get the attribute of session. 8. Run the Project(let serve...

How to validate 'email' using Regular Expression in Java with NetBeansIDE

Image
How to validate 'email' using Regular Expression in Java with NetBeansIDE 1. Open NetBeansIDE 2. In your project Make a java form(e.g. JFrame Form)    2.1 Design this Form with one JTextField and a button in it. 3. Make Validate.java class        3.1 In this class make a static method with code:        public static boolean validateEmail(String email) {                                                boolean status=false;           String EMAIL_PATTERN =         "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"         + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";     ...

How to use Properties File in JAVA

  How to use Properties files of JAVA in NetBeansIDE 1. Open NetBeansIDE. 2. In your project,         2.1 right click on package(any package)     2.2 choose>new>others>others>properties file 3. In properties file, write the 'key' and its 'value'    as     (key)=(value)     (key)=(value)     ..... 4. To access the properties file, make a new java class file and write your code(in video)... 5. Run the file. 6. Finish.   Thank You Click here to visit my facebook page for more videos

How to make simple Dice in JAVA using NetBeansIDE

Image
How to make simple Dice in JAVA using NetBeansIDE 1: Make a netbeans java application project. 2: Make a jFrame form with JLabel and JButton. 3: Copy the required dice images to the default package(or any other package) of the project. 4: Right click on jButton and select Events>Action>actionPerfomed in the popup menu. 5: Write the code. code for the image display on random: Random rd=new Random();         int random=0;         random=rd.nextInt(6)+1;         switch(random){             case 1:                 jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dice1.gif")));                 break;        ...
Image
How to use Getter and Setter functions of Data Transfer Object and Data Access Object. 1. Open NetBeansIDE 2. In a project make a class(DTO) file say 'FileDTO' 3. In FileDTO  3.1. Here I have declared two private String type variables 'name' and 'hobby'  3.2. Right click on source area in netbeans and goto      insert code..-Getter and Setter..  3.3. Choose required variables for which you want to generate Getter and Setter methods  3.4. Click Generate 4. Make another class(DAO) file say 'FileDAO'  4.1. In this file, make a 'static function' & write the code for connection and query       (insert, delete, update, etc)  4.2. Get values of the variables of 'FileDTO' by making an object and calling 'getter'       function 5. Make a JFrame Form say 'NewForm'  5.1. Add JTextFields and a JButton  5.2. For JButton Action-actionPerformed event type the code for 'sett...