I'm trying to run the following java program by using the instructions provided here URL....The program tries to connect to LDAP directory, searches for an objectGUID and returns sAMAccountName...But when I compile the java program I get 19 errors as given below.
/a1/utils/seek.java:2: cannot find symbol
symbol : class string
location : class seek
public static void main (string[] args) {
Four experiments are performed, each consisting of six tests. The number of test results for each experiment is entered by the user. Write a Java program using a nested loop to compute and display the average of the test results for each experiment.
You can run the program by entering the following test results:
I need to design, implement, and test a program to input and analyze a name. The program begins by retrieving a user input string from the keyboard. This string is intended to be the user's name. These are the errors we have to search analyze the user input for: No blanks between names firstName and lastName, Non-alphabetic characters in names, Less than two characters in first name, and Less than two characters in last name. Each of these errors must be thrown. All exceptions must be derived from a programmer-defined class called NameException. Each exception should use a detailed message to differentiate among the file types of errors.
This is the format of my NameException class, is the format itself correct? I will fill in the details of each exception I am just wondering if that is how I should set it up.
public class NameException extends Exception { private String firstName, lastName; public NoBlanksException(String firstName,String lastName) { } public NonAlphabeticalCharactersException(String firstName, String lastName) {
[Code] .....
I was told not to try and catch thrown errors in the main method, would I just create another method in the Driver class to take care of that then?
I want to create a singleton for DirContext for LDAP configuration, hence i have used the initialize on demandclass holder idiom as shown below
public class SlmApplicationContext { /** * inner class to hold the instance. */ private static class Holder { private static DirContext instance = new InitialDirContext(); }
/** * Method to get the singleton instance of this class. * @return SlmApplicationContext */ public static SlmApplicationContext getInstance() { return Holder.instance; } ... }
Now the problem is if i close the DirContext.close(), when the next request comes the singleton wont work as the dir context is already closed, hence it will create a new dir context for each requests. Which breaks the singleton concept, hence how we can ensure the singleton works fine even with DirContext.close()?
I'm doing a program where a user enters in exam results for students. Once he's entered the code, the code should split the results in stars in 4 categories.
I am working with a while loop that prints out infinite results. What I want to do is, if the user enters 2 digits, say "12", it should output 1 "*".
If the user enters "21" and "22", it should output "**".
There are 4 categories of marks which are marked with ints range1, range2, range3 and range4, which are user enter digits. Part 1 of the code is to split the user entered digits into its correct ranges. the ranges are 0-29, 30-39, 40-69 and 70-100. I've done the part where when the user enters a digit, it goes into the correct variable. After that when the user enters a digit over 100, the enter results should show up as stars. For example
Enter number =
21 22 44 66 44 23 11 111 (the 111 is where the program breaks and moves on)
So it should then display
0-29 ****
30-39
40-69 ***
70-100
Whatever I'm trying, it displays an infinite amount of stars. If I try to use break, It only outputs a single star, no matter how many digits I enter
Here is the code
int mark = 0; int range1 = 0, range2 = 0, range3 = 0, range4 = 0; int count1 = 0, count2 = 0, count3 = 0, count4 = 0; while (mark >=0 && mark <=100) {
[Code] .....
"The problem is with the while loop, the one above is something I was experimenting with "
I'm trying to print out the results of a program that calculates the number of seats the parties will get in an election.I have to print the partial results and the national results.
I can print te number of seats per party in each constituency, but how can i sum all seats per party in each constituency and print the national results?I'm working with vectors, which I know it might not be the best option, but everything is working, except the fact that I can't loop throuhg the vector and retrieve the total sum per party.Like, adding the seats for labour party in Constituency A and B and C, etc, and print the sum. And do the same for conservative party.Is it possible, or doIhave to create a method in Parties class to solve the problem?
This is what I have now.
for (Parties p : h.geral) { show += String.format("Constituency - %5s - %5s - %d%n", p.getConstituency(), p.getParty(), p.getNum_seats()); }
I am having the hardest time trying to figure out how to display an array in a 1-window GUI.
I can display 1 book separately, by basically ignoring the array and creating a new object for each book, but I need all 5 books to display in one window, and that's where I'm lost. I'd really like to use the arrayI built to generate the books in the GUI. The information of each book appearing horizontally, and the different books appearing vertically.
// Bookstore.java // This program displays information on multiple books
I am trying to write a loop that calculates the distance traveled (distance = speed * time). It should use the loop to calc how far the vehicle traveled for each hour of time. My program asks for hours and then mph but its not calculating time * speed. Here is my code.
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter Hours Traveled "); int hoursTraveled = input.nextInt(); System.out.println("Enter MPH "); int mph = input.nextInt();
How to do draw the original binary tree based on traversal results?
A binary tree has this pre-order traversal result: A,B,D,H,I,E,F,C,G,K,J (TreeNodes) And the same tree gives the following in-order traversal: B,H,I,D,A,C,F,E,K,G,J. Can you draw the tree structure?
I currently building a hotel reservation system, and I'm having issues with retrieving and setting other values from a JTextField.
What I'm trying to do is to retrieve the value that was inputted into a textfield, and then setting that value to a string in another class.
In here, I'm trying to retrieve values from the JTextField:
@Override public void actionPerformed(ActionEvent event) { GuestInfo gi = new GuestInfo(); if (event.getSource()==roomView) { roomViewFrame.setVisible(true); roomViewFrame.setSize(1000, 600);
This program should create a GUI that has 5 classes together on a grid layout. The problem that I am having is that the user input class has the input for kwh, hours, and gallons. I am having problems getting that information from the user input class to the totals class.
I want to have a button in my Jsp's labeled "next" that takes me to the next JSP in a certain order. Imagine a book: every time you click next you go to the next page.
Each page is a JSP that is named "page#" where # stands for the number (page1, page2,etc).
I was structuring my app this way: one controller,one controllerhelper,multiple JSPs.
The "next" button in the JSP's would always have the same name as not to overcode in my controllerhelper with too many options for the button that was pressed.
So my idea was to retrieve the name of the current JSP and work the string in order to add a number (page4 turns into page5) and forward it through a requestdispatcher.
That is the problem as I am not able to get the name of the current JSP since the url changes after the first page to the servlet url.
I have a properties file with a set of commands and their meanings (Command = the meaning). I Populated a jtree with the keys from the properties file, now when I click a node in the jtree (key) I want the value of that selected key to go in the panel that sits in my app next to the jtree.
I need to take the users input from 2 boxes and reference that to a sqlite database and populate the fields with the data in the database. I know the database code work.
I am trying to export data from a jtable to a pdf report but every time i try running the code it gives me this exception:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at GUI.QC_receiving_book.printButtonActionPerformed(QC_receiving_book.java:309) at GUI.QC_receiving_book.access$600(QC_receiving_book.java:26) at GUI.QC_receiving_book$7.actionPerformed(QC_receiving_book.java:165) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
[Code] ....
I tried avoiding the null exception by using the if statement but it didn't work. The row I choose from the table is full meaning there are no empty attributes. and all the data are imported from a mysql database to the table as String so there can't be any casting errors.
This is the part of the source code with the problem and i will also post the printing method. I tried debugging the class and when stepping into the first if statement it opened the jTable.java file and pointed at the getSelectedRow() method and this sentence "variable information not available.source compiled without -g option"
private void printButtonActionPerformed(java.awt.event.ActionEvent evt) { if(samplesTable.getSelectedRow() >= 0){ int row = samplesTable.getSelectedRow(); System.out.println(row); for(int x=0;x<samplesTable.getColumnCount();x++){ String value = samplesTable.getModel().getValueAt(row, x).toString();
I am creating a simple Symptom Checker application. The problem I have is that I'm trying to retrieve user input (JTextField) by comma's using StringTokenizer which contacts the database for a result which matches the user's input (SELECT * FROM DIAGNOSIS WHERE ?, ?, ?) . It successfully finds the correct result however only in a particular format. Not different combinations....
for example, if I enter say within the JTextField: "tearful, nausea, lack of motivation" it will find the result successfully (as that is how it is formatted within the particular column (in the database table) i wish to display a result from) however, if i enter a different combination of these symptoms: "nausea, lack of motivation, tearful" - it will not find any result. I'm very unsure how to make it work regardless of what is inputted first, second or last.
Here is the code:
public void actionPerformed(ActionEvent e) { try { String abc = fieldsymp1.getText(); StringTokenizer str = new StringTokenizer(abc); while (str.hasMoreTokens()) { str.nextToken((", ")).trim();
i am trying to run a command in terminal the code is below if i run the command in terminal it works fine however when i run it from netbeans with code below nothing gets printed. however if i run a different command such as (ip addr) it works fine?
public static void a() throws IOException{ ArrayList lister=new ArrayList(); Runtime rt = Runtime.getRuntime(); Process proc = rt.exec("ps -ef | grep firefox");// the command i am trying to run to get pid of application InputStream stderr = proc.getInputStream();
I need to print certain information from an arraylist depending on the arguments the method has. I'm trying to print the last 3 methods from the database class but nothing is printing and I don't know what the problem is.
package hw3; import java.util.*; public class Driver { public static void main(String[] args){ /* Comments required PersonFileReader pfr = new PersonFileReader("person.dat"); ArrayList<Person> testData = pfr.readData(); Database db = new Database(testData); */
[Code] .....
On the driver class I just print what the methods from the database class do.
I develop a little app in javaee6 and jsf2. I have a search page which has a search form with 2 fields and a search button when i click search button the results should be displayed in searchresults page.
Issue: searchresults page is is not displaying records though it fetched records from table I'm able to achieve this using search bean as session scope but i want to use the scope as Requestscope.