Viewing: Java

How to set http proxy settings in Eclipse

Eclipse provides users with option to configure the proxy server details. You can set the http proxy settings by following the below steps. Navigate to Windows menu and select Preferences from the list of available menus. Type Network in the text box provided under the Preferences screen. This would display the Network Connections under the […] Read More

What are Class declarations and Modifiers in Java

A class in Java can be declared as shown below class SampleApp { } The above class does not specify any modifiers but in general most of the Java classes declaration will be specified with modifiers. The different modifiers that are allowed in java class declarations are Access Modifiers public protected private Non Access Modifiers […] Read More

How to install Google App Engine Plugin for Eclipse

Google App Engine Plugin for eclipse can be installed using the Help menu –> Install New Software menu option. Click Help Menu and select Install New Software from the list of available menu option. In the Work with text box enter the URL http://dl.google.com/eclipse/plugin/3.6 and click the Add button. Enter the Name in the Add […] Read More

What is a java class?

A class in Java is a classification of an object with similar attributes and behavior. For example Circle, Square, Triangle and Rectangle can be classified in to a Shape class as they exhibit the same behavior and attributes such as sides, area etc. The attributes of a class are the visible properties of a class. […] Read More

My First Java Swing App that prints current date

This is my first java swing app that prints the current date in in JLabel component. Check out the code for this very simple program import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JComponent; import java.util.Date; public class SwingApp extends JFrame{     public static void main(String args[]){         new SwingApp();     }         SwingApp() {         JLabel […] Read More

What is the difference between System.out.println and System.out.print in java

During runtime if you want to print any message in the java console then you can use System.out.println or System.out.print. The difference between System.out.println and System.out.print in java is that println always prints the message in a new line where print displays the same message. For example output of the following code snippet will be […] Read More

javac is not recognized as an external or internal command

javac is the compiler tool in java language which converts the java classes and interfaces in to bytecode class files. When you type javac in Windows command prompt, you might receive the following error 'javac' is not recognized as an internal or external command, operable program or batch file. This could be because the windows […] Read More

What is the signature of main method in a java class?

This is a simple question but nowadays programmers prefer auto generated code by IDEs rather than using any text editors and they have difficult remaining this simple signature. The signature of main method in a java class is public static void example:- public static void main(String[] args) where public defines the access level, static is […] Read More

Rules associated with a Source code File declaration

1. One public class per source code. 2. Comments can appear any where in the code. 3. Name of file should match with the public class name. This is not necessary if a file only has non public class. 4. The order of statements in a class file are package import public class name. 5. […] Read More

Java error – illegal start of type

When you compile a java program as shown below, you would get illegal start of type error. This is because the import statement is with in the class definition. Any import statement should be defined before the class definition and after the package statement (if package statement is declared for a class) package com; public […] Read More

class, interface, or enum expected – compilation error

In Java it is not necessary for a class to have package statement. But if it has then it has to be the first statement. The following class would give a compilation error as  “class, interface, or enum expected” as the package statement defined between import and the class definition. import java.util.*; package com; public […] Read More

Java Compilation error – public, should be declared in a file named

When you compile a Java class with name of the public class not matching the source code file name then you would receive compilation error “public, should be declared in a file”. In the following example, we have the public class name as Test1 but this has been saved as Test.java. public class Test1 { […] Read More

SCJP – Java Identifiers

Java identifiers needs to be a Legal Identifier and it should adhere to Sun’s Java Code Conventions and  JavaBeans Naming standards Rules for Legal Identifier. Start with letters or $ (Currency Character) or _(Underscore). After first character it can be any combination of letters, numbers currency characters. case-sensitive Java Keywords can not be used as […] Read More

SCJP – Java 1.6 Keywords

These are list of Java 1.6 keywords abstract boolean break byte case catch char class const continue default do double else extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch synchronized this throw throws transient try void volatile while […] Read More

1 2

Get your free copies of the following tech guides by joining the Digital Answers mailing list.