Question by Alex: Using semaphores in Java? How can I make threads run at different frequencies to one another?
I have three different threads running in my Java program. One prints “1″, another “2″, and the last “3″. I need to make the “1″s and “2″s print less frequently than the “3″, using semaphores, but I’m very stuck. Any ideas?

Best answer:

Answer by McFate
You could wait on one semaphone between all three threads, and then:

(1) Print “3″ every time you get the semaphore in the “3″ thread
(2) Print “1″ only every second or third time you get the semaphore in the “1″ thread

Add your own answer in the comments!

Question by Dr. Rajkumar Desai: How to create java based dictionary for mobile using data in microsoft excel?
i am having a ms excel file which contains 2 columns, I first column i added words, and in second column meaning to the word in the first column. I want to create a dictionary for mobile like nokia or any java based application running mobile. How it can be created as i, dont know the java programming?

Best answer:

Answer by mhnd_79
you have to learn some Java programming basics
try out this tutorial

http://www.edumax.com/java-basics.html

go ahead till 6-threads and GUI
then you have to learn a little about J2ME which is the platform to run java on mobile phones and it has a little bit different classes
here you can find a small tutorial as well

http://www.tutorialized.com/view/tutorial/Basics-of-J2ME/331

Finally don’t bother using excel in the mobile version, just save it as text (csv for example) and use it in Java

wish you luck

What do you think? Answer below!

Data Structures: Abstraction and Design Using Java

This book lays the foundation for programmers to build their skills. The focus is placed on how to implement effective programs using the JCL instead of producing mathematical proofs. The coverage is updated and streamlined to provide a more accessible approach to programming. They’ll be able to develop a thorough understanding of basic data structures and algorithms through an objects-first approach. Data structures are discussed in the context of software engineering principles. Updated case

Rating: (out of 5 reviews)

Price: $ 86.21

Develop professional enterprise Java EE applications quickly and easily with this popular IDE using a book by Packt

This book shows you how to use NetBeans functionality to automate many of the tedious or repetitive tasks frequently encountered when developing enterprise Java applications, freeing up the developer to focus on the business logic specific parts of the application.

Java EE, the successor to J2EE, greatly simplifies the development of enterprise applications. The popular IDE, NetBeans, has several features that greatly simplify Java EE development, and this book shows you how to make use of these features to make your Java programming more efficient and productive than ever before.

With many features and great flexibility, the Java developer can become overwhelmed by the options available in NetBeans, This book helps you get control of the environment, and make it work for you so that you can concentrate on the important parts of your application.

This book takes you through the most important parts of Java EE programming and, with clear, careful instructions and screenshots, shows you how to use the features of NetBeans that will improve your development experience. This book will not only show you time-saving tricks, keyboard shortcuts and other productivity enhancements possible with NetBeans, it will take you through the major Java EE APIs and how to get them working in the NetBeans environment.

While focusing on NetBeans features, you will learn about developing applications using the servlet API and JSPs, including taking advantage of JSTL and developing custom JSP tags. Developing applications that take advantage of JavaServer Faces is also covered in detail, including how to generate standard JSF applications from an existing database schema. The book also covers how to easily develop elegant JSF applications by taking advantage of the NetBeans Visual Web designer.

The book is aimed at Java developers who wish to develop Java EE applications while taking advantage of NetBeans functionality to automate repetitive tasks and to ease their software development efforts. Familiarity with Java EE is not assumed.

You can read more about the book herehttp://www.packtpub.com/java-ee5-development-with-netbeans-6/book

Modern Software Development Using Java, Second Edition

Now updated for the latest release of Java, the Second Edition of Modern Software Development Using Java continues to blaze a new path for today’s CS2 students. Tymann and Schneider’s contemporary approach focuses on what students need to learn in the CS2 course in order to appreciate what is truly important today in the areas of software design and development. This text covers such current software development ideas as object-oriented design, UML, data structure libraries, net-centric programm

Rating: (out of 1 reviews)

List Price: $ 156.95

Price: $ 62.11

Related Java Products

Accessing Ms Access Using Java

Accessing Ms Access Using Java

Step by step guide:

1.Create a database in ms access and add a table

2.Add columns to the table.

3.Go to control panel->Administrative Tools

->JDBC-> System DSN

4.In System DSN tab click on add ,choose

Microsoft access driver ,then you will get a

dialog box opened ODBC Microsoft access setup

mention the data source name in it and in

databases click on select button and choose

your .mdb file that is created in step1.

5.Register the driver using

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

6.Connect to the database

Connection con = DriverManager.getConnection

(URL,userid,password);

url=” Jdbc:Odbc:”

userid and password are empty in case of MS access.if it oracle default userid is “scott” password is “tiger”.

Ex: Connection con = DriverManager.getConnection

( “Jdbc:Odbc:msac”, “”,”");

Source Code

import java.sql.*;

import java.io.*;

class JdbcDemo1

{

Connection con;

Statement stmt;

ResultSet rs;

JdbcDemo1(){

try{

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

con = DriverManager.getConnection( “Jdbc:Odbc:msac”, “”,”");

stmt = con.createStatement();

rs = stmt.executeQuery(“SELECT * FROM Table1″);

while (rs.next()) {

String x = rs.getString(“name”);

int s = rs.getInt(“age”);

System.out.println(“x:”+x+”s”+s);

}

}catch(SQLException e){

System.out.println(“Hello World!”+e);

}catch(ClassNotFoundException e){

System.out.println(“purni”+e);

}

}

}

class JdbcDemo

{

public static void main(String args[]){

new JdbcDemo1();

}

}

Objects First With Java: A Practical Introduction Using BlueJ (4th Edition)

The BlueJ development environment was specifically designed to support introductory teaching of object-orientations and helps users grasp the complicated concepts of class structure. Unlike most books on the subject, this text uses BlueJ to get readers started on object-oriented programming from day one. Uses a spiral approach that introduces a topic in a simple context early on, then revisits it later to increase understanding; Offers an abundance of projects for hands-on practice; Chapters a

Rating: (out of 32 reviews)

List Price: $ 108.00

Price: $ 80.00

Question by Juliette: How would I create a Java program using arrays to examine temperature?
What would coding look like that took user input of 10 temperatures and told if each day was above average based off the average of the ten day input.

Thanks!

This is more or less to help me understand so that I can help my daughter with her work–I don’t understand much about Java programming.

Best answer:

Answer by Ya it’s me….
Here’s the easiest way:

Server-side code:

System.Text.StringBuilder javaScript = new System.Text.StringBuilder();
DataTable dataTable = this.CreateTestDataSource();

for (int i=0; i {
if (i == 0)
{
javaScript.Append("\n");
}
else
{
javaScript.Append(",\n");
}
}
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ArrayScript", javaScript.ToString());

protected virtual DataTable CreateTestDataSource()
{
DataTable dataTable = new DataTable("TestDataTable");
dataTable.Locale = System.Globalization.CultureInfo.InvariantCulture;

dataTable.Columns.Add(new DataColumn("ID", typeof(string)));
dataTable.Columns.Add(new DataColumn("Subject", typeof(string)));

{
DataRow dataRow = dataTable.NewRow();
dataRow[0] = "0";
dataRow[1] = "Test0";
dataTable.Rows.Add(dataRow);
}
{
DataRow dataRow = dataTable.NewRow();
dataRow[0] = "1";
dataRow[1] = "Test1";
dataTable.Rows.Add(dataRow);
}

return dataTable;
}

Client-side code to test with:

NC...

Know better? Leave your own answer in the comments!

Build Powerful Java Applications Using Soa With New Book From Packt

This book shows how to use SOA and web services to build powerful applications in Java. It teaches the concepts and the implementation with best-practice real-world examples. You will learn to design a sound architecture for successful implementation of any business solution, the different types of architecture, and various tenets of SOA. The book explains the fundamentals and the advantages of using the Service Oriented Architecture in designing your business solution.

In Detail: Service Oriented Architecture provides a way for applications to work together over the Internet. Usually, SOA applications are exposed through web services.

Web services have been around for a while, but complex adoption processes and poor standardization hampered their use at first. However, with the adoption of new, simpler protocols such as REST, and major companies supporting SOA, the time is now right to adopt these standards.

This book will show you how to build SOA, web services-based applications using Java. You will find out when SOA is the best choice for your application, how to design a sound architecture, and then implement your design using Java.

The book covers the important web services protocols: XML-over-HTTP, REST, and SOAP. You will learn how to develop web services at all levels of complexity and for all kinds of business situations.

Approach:This book is an overview of how to implement SOA using Java with the help of real-world examples. It briefly introduces the theory behind SOA and all the case studies are described from scratch.

The book is out now and is available from Packt. For more information, please visit: http://www.packtpub.com/service-oriented-architecture-for-java-applications/book

Related Java Articles

Java Programming – Accessing Databases Using Jdbc

JAVA PROGRAMMING – ACCESSING DATABASES USING JDBC

You can access databases using JAVA. The special feature available in Java for this purpose is Java Database Connectivity (JDBC).

You have to create a database in MS Access or Oracle or MySQL or any other database management system. Then give an ODBC name for your database.

Visit

http://learnjavatoday.blogspot.com

For more details

// The following example illustrates how to display a table in

// JAVA using

// Java Database Connectivity (JDBC).

// Before running the program, create a table

// named as BOOKS in Oracle 9i.

// Declare the database giving ODBC Name bk.

// User Name is kt.

// Password is kt.

// Save File as MyTable.java

// Assuming that your java bin directory is C:\java\bin

// Compile the file using

// C:\java\bin javac MyTable.java

// to create MyTable.class file.

// Execute the program using

// C:\java\bin java MyTable.

import java.sql.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

public class MyTable extends JFrame {

private Connection connection;

private JTable table;

public MyTable()

{

String url=”jdbc:odbc:bk”;

String username =”kt”;

String password=”kt”;

try {

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

connection=DriverManager.getConnection(url,username,password);

}

catch(ClassNotFoundException cnfex) {

System.err.println(“Failed to load JDBC/ODBC driver.”);

cnfex.printStackTrace();

System.exit(1);

}

catch( SQLException sqlex ) {

System.err.println(“Unable to connect”);

sqlex.printStackTrace();

}

getTable();

setSize(450,150);

show();

}

private void getTable()

{

Statement statement;

ResultSet resultSet;

try {

String query = “SELECT * FROM BOOKS”;

statement = connection.createStatement();

resultSet=statement.executeQuery(query);

displayResultSet(resultSet);

statement.close();

}

catch ( SQLException sqlex) {

sqlex.printStackTrace();

}

}

private void displayResultSet(ResultSet rs) throws SQLException

{

boolean moreRecords=rs.next();

if (!moreRecords) {

JOptionPane.showMessageDialog(this,”ResultSet contained no records”);

setTitle(“No records to display”);

return;

}

setTitle(“Authors table from Books”);

Vector columnHeads=new Vector();

Vector rows=new Vector();

try{

ResultSetMetaData rsmd=rs.getMetaData();

for ( int i=1; i

columnHeads.addElement(rsmd.getColumnName(i));

do{

rows.addElement(getNextRow(rs,rsmd));

} while (rs.next());

table=new JTable(rows,columnHeads);

JScrollPane scroller=new JScrollPane(table);

getContentPane().add(scroller,BorderLayout.CENTER);

validate();

}

catch(SQLException sqlex) {

sqlex.printStackTrace();

}

}

private Vector getNextRow(ResultSet rs,ResultSetMetaData rsmd) throws SQLException

{

Vector currentRow= new Vector();

for (int i=1; i

switch(rsmd.getColumnType(i)) {

case Types.VARCHAR:

currentRow.addElement(rs.getString(i));

break;

case Types.DECIMAL:

currentRow.addElement(new Long(rs.getLong(i)));

break;

default:

System.out.println(“Type was: “+rsmd.getColumnTypeName(i));

}

return currentRow;

}

public void shutDown()

{

try{

connection.close();

}

catch(SQLException sqlex) {

System.err.println(“Unable to disconnect”);

sqlex.printStackTrace();

}

}

public static void main(String args[])

{

final MyTable app=new MyTable();

app.addWindowListener(

new WindowAdapter() {

public void windowClosing(WindowEvent e)

{

app.shutDown();

System.exit(0);

}

}

);

}

}

// For more details see Java How To Program