Help. Thing won't compile!!!!
Homework Assignment help!
Have four classes. Grade, Group, CreateGroup, Inquiry.
Grade compiles. Group compiles. CreateGroup compiles.
Having trouble with Inquiry in the process().
Please help. When I try to compile Inquiry I get IOException not caught at
group = create.loadFromInput();
when I try and catch it, I get nullpointerexception!!
Grade
import java.util.Arrays;
/** Get student ID, student name, array of quiz scores,
compute average, computer letter grades.
public class Grade
private final int STUDENT_ID_LENGTH = 4;
private String studentID;
private String studentName;
private double quizScores[];
private double averageQuizScore;
private char grade;
/** This constructor initializes ID, name and scores.
@param ID The student ID
@param name The Student name
@param scores The student quiz scores.
@throws IllegalArgumentException if argument is null or empty
@throws IllegalArgumentException if Student Id is not valid
public Grade(String id, String name, double[] scores)
throws IllegalArgumentException
char[] idChars = new char[STUDENT_ID_LENGTH];
if(id == null || id.trim().length() == 0) // If ID is null or length of ID is 0
throw new IllegalArgumentException("The student ID is null");
else if(id.trim().length() != 4) // If length of ID is not 4
throw new IllegalArgumentException("Student ID not 4 digits: "
+ id.trim());
else if(name == null || name.trim().length() == 0) // If name is null or length of name is 0
throw new IllegalArgumentException("Student Name is null");
else if(scores == null || scores.length == 0) //If scores is null or length of scores is 0
throw new IllegalArgumentException("There are no quiz scores");
id = id.trim();
id.getChars(0, STUDENT_ID_LENGTH, idChars, 0);
for(int index = 0; index < idChars.length; index++)
if(!Character.isDigit(idChars[index])) //if not digits then throw exception
throw new IllegalArgumentException("Student ID is not 4 digits: "
+ id.trim());
studentID = id; // set the value of studentID to ID
studentName = name; //set the value of studentName to name.
quizScores = (double[])scores.clone(); // cloning quizScores
averageQuizScore();
grade();
/** This method calculates the average quiz score
@param averageQuizScore the average quiz score
private void averageQuizScore()
double total = 0.0;
if (quizScores.length == 1) //If length of quizscores is 1 then average score is the score.
averageQuizScore = quizScores[0];
else if (quizScores.length == 2) // If length is 2, average score is average of the scores.
averageQuizScore = (quizScores[0] + quizScores[1]) / 2;
else
double lowestScore = quizScores[0];
//index is equal to length of quizscores - 1 and when index >= 0, decrement index
for(int index = quizScores.length - 1; index >= 0; index--)
total += quizScores[index];
if(quizScores[index] < lowestScore)
lowestScore = quizScores[index];
averageQuizScore = (total - lowestScore) /
(double)(quizScores.length - 1); // drop the lowest score.
/** This method calculates the letter grade.
@param grade The letter grade
private void grade()
if (averageQuizScore < 60)
grade = 'F';
else if (averageQuizScore < 70)
grade = 'D';
else if (averageQuizScore < 80)
grade = 'C';
else if (averageQuizScore <90)
grade = 'B';
else if (averageQuizScore > 90)
grade = 'A';
/** This method returns the student ID
@return The student ID
public String getStudentID()
return studentID;
/** This method returns the student Name
@return the student name
public String getStudentName()
return studentName;
/** This method returns the student quiz scores
@return the student quiz scores
public double[] getQuizScores()
return (double[])quizScores.clone();
/** This method returns the average quiz scores
@return the average quiz scores
public double getAverageQuizScore()
return averageQuizScore;
/** This method returns the letter grade
@return The student letter grade
public char getAverageQuizGrade()
return grade;
/** This method returns a string representation of the object
@return The string representation of object
public String toString()
return ("Student ID:" + studentID + "; Student Name:" + studentName
+ "; Student Average:" + averageQuizScore + "; Student Grade:" +
grade + "; Student Scores:") + Arrays.toString(quizScores);
}Group
/** This class adds, retrieves, removes grade objects and returns array of IDs
public class Group
public static final int MAXIMUM_STUDENTS = 60;
private static final int NOT_FOUND = -1;
private int actualStudents;
private String idArray[];
private Grade gradeArray[];
/** The default constructor creates empty arrays
public Group()
idArray = new String[MAXIMUM_STUDENTS];
gradeArray = new Grade[idArray.length];
/** This method adds a Grade object and returns true when information added
and false when information is not added.
@param studentID The Student ID
@param studentRecord The Grade object
public boolean add(String studentID, Grade studentRecord)
boolean status = false;
if(NOT_FOUND == getStudentIndex(idArray, studentID))
if(actualStudents == MAXIMUM_STUDENTS)
System.err.println("There are more student recors than can be"
+ "handled, extra records are discarded.");
else
idArray[actualStudents] = studentID;
gradeArray[actualStudents] = studentRecord;
actualStudents++;
status = true;
else
System.err.println("Error with record;" + " (This ID is duplicate: "
+ studentID + "); record discarded");
System.err.println("Record Content: " + studentRecord);
return status;
/** This method uses student ID to get the student id, student name
and student quiz scores
@param ID The student ID
@return The instance of Grade
public Grade get(String studentID)
Grade grade = null;
int index = getStudentIndex(idArray,studentID);
if(index != -1)
grade = gradeArray[index];
return grade;
/** This method uses the student ID to remove the student's id,
name, scores
@param studentID The student ID
@return A reference to removed object or null for no student id.
public Grade remove(String studentID)
Grade grade = null;
int index = getStudentIndex(idArray, studentID);
if(index != -1)
grade = gradeArray[index];
for( int i = index; i < actualStudents - 1; i ++)
gradeArray[index] = gradeArray[index + 1];
idArray[index] = idArray[index + 1];
gradeArray[actualStudents - 1] = null;
idArray[actualStudents - 1] = null;
actualStudents--;
return grade;
/** This method returns the Student ID array in ascending order
@return The sorted Student ID array
public String[] getIDs()
insertionSort(idArray, gradeArray);
return idArray;
/** This method returns the index of the Grade Object in the Array
@param studentID The student ID
@param array The Array to look in
@return The student index in the array
private int getStudentIndex(String[] array, String studentID)
return binarySearch(array, 0, actualStudents - 1, studentID);
/** This method performs a recursive binary search on String array
@param array The array to search
@param first The first element in the search range
@param last The last element in the search range.
@param value The value to search for.
@return The subscript of the value if found, otherwish -1.
private int binarySearch(String[] array, int first, int last, String id)
int middle;
if(first > last)
return -1;
middle = (first + last) / 2;
if (array[middle].equals(id))
return middle;
else if (array[middle].compareTo(id) < 0)
return binarySearch(array, middle + 1, last, id);
else
return binarySearch(array, first, middle - 1, id);
/** This method performs an insertion sort on String arrays.
The arrays is sorted in ascending order.
@param idArray the ID array to sort
@param gradeArray The grade array to sort
private void insertionSort(String[] idArray, Grade[] gradeArray)
String unsortedID;
Grade unsortedGrade;
int scan;
for(int index = 1; index < actualStudents; index ++)
unsortedID = idArray[index];
unsortedGrade = gradeArray[index];
scan = index;
while (scan > 0 && idArray[scan - 1].compareTo(unsortedID) > 0)
idArray[scan] = idArray[scan - 1];
gradeArray[scan] = gradeArray[scan - 1];
scan--;
idArray[scan] = unsortedID;
gradeArray[scan] = unsortedGrade;
}CreateGroup
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
/** Create an object of Grade class, load the object from the file,
and write the object to data file
public class CreateGroup
final int MAXIMUM_STUDENTS = 60;
String studentRecord;
String studentID;
String studentName;
int actualStudents;
String input = "CS076C16B_Input.txt";
String output = "CS076C16B_Output.txt";
Group group;
/** Read the input file and validate it and print good records to output file.
public Group loadFromInput() throws IOException
group = new Group();
int index = 0;
BufferedReader inputFile = new BufferedReader(new FileReader(input));
studentRecord = inputFile.readLine();
while(studentRecord != null && actualStudents < MAXIMUM_STUDENTS)
index++;
String tokens[] = studentRecord.split(",");
double scores[] = new double[tokens.length - 2];
for(int i = 0; i < scores.length; i++)
scores[i] = Double.parseDouble(tokens[i+2]);
try
Grade grade = new Grade(tokens[0], tokens[1], scores);
if(group.add(studentID, grade))
actualStudents++;
catch(IllegalArgumentException illegalargumentexception)
System.err.println("Error with record " + index + "; " +
illegalargumentexception.getMessage() + "; record discarded");
System.err.println("Record content: " + studentRecord);
if(actualStudents == MAXIMUM_STUDENTS && studentRecord != null)
System.err.println("There are more student records than can be"
+ "handled, extra records are discarded.");
inputFile.close();
return group;
/** This method writes Grade objects out to a data file in ascending order
public boolean saveFile()
Grade grade;
boolean successful = false;
String holdLine;
String[] studentIDs = group.getIDs();
try
FileWriter fwriter = new FileWriter(output);
PrintWriter output = new PrintWriter(fwriter);
for(int i = 0;i < actualStudents; i++)
grade = group.get(studentIDs);
studentID = grade.getStudentID();
studentName = grade.getStudentName();
double[] scores = grade.getQuizScores();
holdLine = studentID + "," + studentName;
for(int index = 0; index < scores.length; index++)
holdLine += "," + scores[index];
output.println(holdLine);
output.close();
successful = true;
catch(IOException e)
System.err.println(e.getMessage());
return successful;
Inquiryimport java.util.Scanner;
import java.util.Arrays;
import java.io.IOException;
/** This class prompts the user to add, delete, retrieve or
save student information.
public class Inquiry
CreateGroup create;
Group group;
String studentID;
final int EXIT_SENTINEL = 0;
Scanner keyboard = new Scanner(System.in);
public static void main(String[] args)
Inquiry inquiry = new Inquiry();
inquiry.process();
/** This method gets information from user
private void process()
String input;
CreateGroup create = new CreateGroup();
char retrieve = 'R';
char delete = 'D';
char add = 'A';
char save = 'S';
final String OUTPUT_MESSAGE = "\n Enter " + retrieve +
" to retrieve a student record " + "\n Enter " + delete +
" to delete a student record " + "\n Enter " + add +
" to add a student record " + "\n Enter " + save +
" to save a student record ";
group = create.loadFromInput();
System.out.println("Hello." + OUTPUT_MESSAGE);
input = keyboard.nextLine();
while(input.length() != 0)
char hold = input.charAt(0);
switch(hold)
case 'R':
retrieve();
break;
case 'D':
delete();
break;
case 'A':
add();
break;
case 'S':
save();
break;
/** This method gets the student id, student name and student quiz scores
and adds it to the file
private void add()
String studentName;
String holdScores;
System.out.println("Please enter a Student ID to add");
studentID = keyboard.nextLine();
System.out.println("Please enter the Student's Name");
studentName = keyboard.nextLine();
System.out.println("Please enter the scores, and seperate them" +
"with a ','");
holdScores = keyboard.nextLine();
String[] tokens = holdScores.split(",");
double scores[] = new double[tokens.length];
try
for(int i = 0; i < tokens.length; i++)
scores[i] = Double.parseDouble(tokens[i]);
Grade grade = new Grade(studentID, studentName, scores);
if(group.add(studentID, grade))
System.out.println("Record added successfully");
catch(IllegalArgumentException illegalargumentexception)
System.err.println("Error with record; " +
illegalargumentexception.getMessage());
/** This method gets the student id from the user and deletes the
student Info from the file.
private void delete()
System.out.println("Enter the student ID to delete:");
studentID = keyboard.nextLine();
if(group.remove(studentID) != null)
System.out.println("Record deleted successfully");
/** This method gets the student id from the user and retrieves the student Info.
private void retrieve()
Grade grade;
System.out.println("Enter the student ID to retrieve:");
studentID = keyboard.nextLine();
grade = group.get(studentID);
System.out.println("ID" + grade.getStudentID() +
"; Name:" + grade.getStudentName() + "; Scores:" +
Arrays.toString(grade.getQuizScores()));
/** This method saves the file.
private void save()
if(create.saveFile())
System.out.println("The file was successfully saved.");
}Edited by: pranavss11 on Oct 12, 2008 6:45 AM
Changed process a bit
private void process()
CreateGroup create = new CreateGroup();
String userInput;
int retrieve = 1;
int delete = 2;
int add = 3;
int save = 4;
final String RETRIEVE = "retrieve a student record";
final String DELETE = "delete a student record";
final String ADD = "add a student record";
final String SAVE = "save a student record";
String[] options = {RETRIEVE, DELETE, ADD, SAVE};
final String OUTPUT_MESSAGE = "\n Enter " + retrieve + " to " +
options[retrieve - 1] +
"\n Enter " + delete + " to " + options[delete - 1] +
"\n Enter " + add + " to " + options[add - 1] +
"\n Enter " + save + " to " + options[save - 1] +
"\n Enter " + EXIT_SENTINEL + " or the enter key to exit";
final String REPEAT_OUTPUT_MESSAGE = "Enter " + retrieve + ", " +
delete + ", " + add + ", or " + save + " to" +
" preform a task or " + "0 or the enter" + " key to exit.";
try
group = create.loadFromInput();
catch(IOException e)
System.err.println(e.getMessage());
//Ask the user if they want to retrieve, delete, add, load, or save information
System.out.println("Welcome to Student Inquiry." +
" What do you want to do?" + OUTPUT_MESSAGE);
userInput = keyboard.nextLine();
while (userInput.length() != EXIT_SENTINEL)
try
//try to convert userInput into an integer
int optionNumber;
optionNumber = Integer.parseInt(userInput);
if (optionNumber > 0 && optionNumber < 5)
//echo user input
System.out.println("You chose to " + options[optionNumber - 1]);
switch (optionNumber)
case 1:
retrieve();
break;
case 2:
delete();
break;
case 3:
add();
break;
case 4:
save();
break;
else if (optionNumber == EXIT_SENTINEL)
System.exit(0);
else
System.out.println("The input " + optionNumber +
" is not a valid" + " choice. " + REPEAT_OUTPUT_MESSAGE);
catch (NumberFormatException e)
System.out.println("The input " + userInput + " is not a" +
" valid choice. " + REPEAT_OUTPUT_MESSAGE);
System.out.println("\n What do you want to do next?" + OUTPUT_MESSAGE);
userInput = keyboard.nextLine();
if (userInput.length() == EXIT_SENTINEL)
System.exit(0);
}Exception in thread "main" java.lang.NullPointerException
at Group.binarySearch(Group.java:137)
at Group.getStudentIndex(Group.java:117)
at Group.add(Group.java:33)
at CreateGroup.loadFromInput(CreateGroup.java:53)
at Inquiry.process(Inquiry.java:55)
at Inquiry.main(Inquiry.java:25)
Similar Messages
-
This is my first in depth attempt to understand the code for enabling arrays. I THINK I have a fairly simple problem, but the code won't compile and NetBeans is telling me I'm missing a symbol &/or class, which I just don't get. Here is the code for the Inventory1 module as well as the main module - what am I not seeing?
Inventory1 module
import java.util.Scanner;
import static java.lang.System.out;
public class Inventory1
//declare and initialize variables
int[] itemNumber = new int [5];
String[] productName = new String[5];
int[] stockAmount = new int[5];
double[] productCost = new double[5];
double[] totalValue = new double[5];
int i;
//int i = 0;
//initialize scanner
Scanner sc = new Scanner(System.in);
Inventory1 info = new Inventory1
public void inventoryInput()
while (int i = 0; i < 5; i++)
out.println("Please enter item number: "); //prompt - item number
info.itemNumber[i] = sc.nextInt(); // input
out.println( "Enter product name/description: "); //prompt - product name
info.productName[i] = sc.nextLine(); // input
out.println("Quantity in stock: "); // prompt - quantity
int temp = sc.nextInt(); // capture temp number to verify
if( temp <=0 )
{ // ensure stock amount is positive number
out.println( "Inventory numbers must be positive. Please" +
"enter a correct value." ); // prompt for correct #
temp = sc.nextInt(); // exit if statement
else info.stockAmount[i] = temp; // input
out.println("What is the product cost for each unit? "); // prompt - cost
double temp2 = sc.nextDouble();
if( temp <=0 )
out.println( "Product cost must be a positive dollar " +
"amount. Please enter correct product cost." );
temp2 = sc.nextDouble();
else info.productCost[i] = temp2;
out.println( "We hope this inventory program was helpful. Thank you for " +
"using our program." );
} // end method inventoryInput
}main module
public class Main {
public static void main(String[] args) { //start main method
Inventory1 currentInventory = new Inventory1(); //call Inventory class
currentInventory.inventoryInput();
}init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\build\classes
C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:28: '(' or '[' expected
public void inventoryInput()
C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: '.class' expected
while (int i = 0; i < 5; i++)
C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: illegal start of type
while (int i = 0; i < 5; i++)
C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: not a statement
while (int i = 0; i < 5; i++)
C:\Documents and Settings\Tammy\My Documents\School\JavaProgramming\Inventory\src\inventory\Inventory1.java:30: ';' expected
while (int i = 0; i < 5; i++)
5 errors
BUILD FAILED (total time: 0 seconds) -
Hi,
I'm trying to migrate my application from JDev 11.1.1.0.2 to 11.1.2.2.0 but even after Jdev migrate to new version, the application won't compile correct. Seems that some classes wont recognize dependecies from other package. If i have a class in Web that import a class from Model, in compile time the console give me this kind a error: "package 'xxx.yyy.www' does not exist". If i open any class that gave me this error there isn't any warning or red line showing errors, in the line of the import i can use Ctrl + right click and go to the class without problems. The dependecies between projects (web, model and ejb) are correct. I dont know what is, any help will be appreciated.
Thanks in advance,
Alexandre Rocco.Hi
I am facing the same problem when migrating from JDev 11.1.1.4.0 to JDev 11.1.2.2.0. Any idea?
Regards,
Ferez -
DG4ODBC MSSQL query works in sql, but won't compile in PL/SQL.
I'm using DG4ODBC from 11g to query a SQL Server database. The query I'm using works in a SQL DEveloper SQL worksheet and sqlplus, but won't compile in a PL/SQL procedure.
The query is
INSERT
INTO crm_labels
accountid,
label_name,
cir_labelcode,
cir_knownasname,
cir_countryidname,
parentaccountidname,
cir_customertypecode1,
cir_customertypecode2,
cir_dealstatus
SELECT "AccountId",
REPLACE("Name",chr(0)) label_name,
REPLACE("Cir_labelcode",chr(0)) ,
REPLACE("Cir_knownasname",chr(0)),
REPLACE("cir_countryidName",chr(0)),
REPLACE("ParentAccountIdName",chr(0)),
"Cir_customertypecode1",
"Cir_customertypecode2",
"Cir_dealstatus"
FROM "dbo"."Account"@crmsvc
WHERE "Cir_labelcode" IS NOT NULL;The error message is
Error(1): ORA-04052: error occurred when looking up remote object dbo.Account@CRMSVC ORA-01948: identifier's name length (34) exceeds maximum (30)I'm guessing that it is attempting to describe additional columns in the Account table.
If I remove the dbo,
FROM "Account"@crmsvcI get
Error(1): ORA-04052: error occurred when looking up remote object PUBLIC.Account@CRMSVC ORA-00604: error occurred at recursive SQL level 1 ORA-28500: connection from ORACLE to a non-Oracle system returned this message: [Microsoft][ODBC SQL Server Driver][SQL Serve which is less than helpful. However, if I try to use the same query to create a materialized view, I get.
SQL Error: ORA-04052: error occurred when looking up remote object PUBLIC.Account@CRMSVC
ORA-00604: error occurred at recursive SQL level 1
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address1_TimeZoneRuleVersionNu'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address1_UTCConversionTimeZone'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address2_TimeZoneRuleVersionNu'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Address2_UTCConversionTimeZone'. {42S22,NativeErr = 207}[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'Pias_NewLabelInDealNotificatio'. {42S22,NativeErr = 207}
ORA-02063: preceding 2 lines from CRMSVCwhich seems to confim that in some circumstance, oracle will attempt to parse more than was asked for.
Any work arounds?
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
DG4ODBC is also 11.2.0.3The gateway claims about this column "Address1_TimeZoneRuleVersionNu" which is not listed in your select list.
When a gateway connection is established it first checks out all columns of the table you want to select to determine the data types and then it fetches the data for the columns you want to select. But there's also an exception - when you use functions the gateway is not able to translate into the syntax of the foreign database. in this case ALL columns will be fetched into the Oracle database and the result is processed locally (post processing).
You're using replace function which won't be mapped to the foreign database equivalent using DG4ODBC so it will post process the result and fetch from all columns all the data into the Oracle database. Your table contains a column which exceeds the 30 character limitation of Oracle, hence the select will fail.
The only work around is to create a view on the foreign database side which reduces the column name length to 30 characters or less. -
Robohelp for Word won't compile
Hi,I've been trying to get one of my projects to work in Robohelp for Word. But the minute I create a second topic the compiled doen't work. there are no errors. the compilation just never starts. This also happens when I rename the first topic to something else.
I have the following configurations:
Robphelp for Word 7 build 145
MS Office Work 2007
windows XP professional with service pack 3
I have deleted and started the project from scratch several times without any success. Any help would be highly appreciated
Thanks
EdnaHi,
Thanks for your reply. The problem is there even with tutorial files and dummy projects.
It seems that there is a problem with saving the document. If I don’t add anything the projects will compile problery. But the minute I change something it won't compile. When I want to close the word document I get a meesage saying if I would like Robohelp to save the document. If I press on "yes" nothing happens. If I press on "yes to all" nothing happens. Pressing on "no" closes the document.
I have setup my word 2007 in a way so it will save .doc formats instead of .docx. But either way it makes no different the problem is with both file formats. -
Help CS6 won't load?????
Hi I'm trying to run CS6 on a Mac Book Pro all has worked fine until recently, now it won't load! I have tried reinstalling but get the following error messages DW063 and DW050 help.
Things to try.
Create a small blank animation and move an object, then export that out to try importing the test file.
Reset the preferences by holding down the modifier keys while photoshop starts.
Reset the tools, found in the top toolbar at far left side.
Uninstall then reinstall photoshop. -
The Plug-in window (I/O thing) won't open, so I can't access my plugins...What do I do?
When i double click on the window i am unable to change it from EVP88 Electric Piano in the left hand sidebar.
When I watch tutorials on how to use parts of logic, people use the I/O as a menu, whereas it does not do that for me.In the online Help type Basic Operations
From the List choose.. Basic Operations then in the left hand menu choose.. Using The Mouse.
Look at the list of mouse operations, I think it's the third one down.
Read how many different mouse operations Logic responds to.
If you really want to learn Logic, reading the manual is a good thing, not only to find what you're looking for but of of the extra/related information you will find as you solve your original question. -
[SOLVED] ruby-panelapplet2 won't compile (i686 & x86_64)
Hi!
I already wrote forum post in 64 bit section, but today I got to i686 machine and the error is the same, that damned package won't compile
Can anyone help getting this compiled? Any hints?
Errors are as follows:
Package 'glipper' has no Name: field
checking for GCC... yes
checking for rb_define_alloc_func() in ruby.h... yes
checking for rb_block_proc() in ruby.h... yes
checking for new allocation framework... yes
checking for attribute assignment... no
checking for libpanelapplet-2.0 version (>= 2.6.0)... yes
checking for G_PLATFORM_WIN32... no
creating rbpanelappletversion.h
creating Makefile
creating Makefile
/tmp/yaourt-tmp-user/aur-ruby-panelapplet2/ruby-panelapplet2/src/ruby-gnome2-all-0.19.1/glib/src/lib/pkg-config.rb:85:in `name': undefined method `[]' for nil:NilClass (NoMethodError)
from /tmp/yaourt-tmp-user/aur-ruby-panelapplet2/ruby-panelapplet2/src/ruby-gnome2-all-0.19.1/glib/src/lib/mkmf-gnome2.rb:165:in `create_pkg_config_file'
from /tmp/yaourt-tmp-user/aur-ruby-panelapplet2/ruby-panelapplet2/src/ruby-gnome2-all-0.19.1/panel-applet/extconf.rb:30:in `<main>'
extconf.rb: Leaving directory 'panel-applet'
That is driving me crazy, coz I can't get SSHMenu work properly and that is one of the tools I use all the time
If someone has that package in x86_64, please send that to me (edzis123[@]inbox.lv). Please remove all numbers and brackets from there
If the package is not available, alternate way is sending the files in the package, I suppose these should be like this (I took sample from i686):
/usr/lib/ruby/site_ruby/1.9.1/panelapplet2.rb
/usr/lib/ruby/site_ruby/1.9.1/x86_64-linux/panelapplet2_main.so
/usr/lib/ruby/site_ruby/1.9.1/x86_64-linux/panelapplet2.so
Thanx in advance.
Last edited by Kirurgs (2010-02-21 21:32:26)Hi!
After spending quite a lot of time on this, I found the error why I couldn't compile almost any of ruby packages including ruby-gnomepanel2.
To my big surprise, pacman -R glipper fixed the issue and I'm now using sshmenu w/o any issues.
Ruby seems to broke if some additional (possibly incorrect) packages are installed, which it shouldn't!! Uff...
regards
Kirurgs
Last edited by Kirurgs (2010-02-21 21:32:57) -
FtpClient client.delete("file") won't compile?
Hello Fine People,
I have this ftp program that is working, except for the delete command:
import sun.net.ftp.*;
import sun.net.*;
String server = "192.168.0.0";
String user = "me";
String passwd = "mypassword";
FtpClient client = new FtpClient();
client.openServer(server);
client.login(user, passwd);
TelnetInputStream tis = null;
client.binary();
client.cd("Composites");
tis = client.list();
client.get("filename");
client.delete("filename");
This is roughly how it is. Without the last line, it compiles and runs fine. But when I add the client.delete line, it won't compile and gives this error:
ImageTransfer.java:229: cannot resolve symbol
symbol : method delete (java.lang.String)
location: class sun.net.ftp.FtpClient
client.delete("filename");
Please help!
- LoganYes. The class you should be importing is, obviously, FTPClient. But don't waste your time trying to compile what is clearly just a code fragment example. The article lists several sources of FTP client software. Once you have chosen one package to evaluate, write your test program using the actual classes from that package, using its API documentation for guidance.
-
I have had success in one of my servlets using JavaMail. I was able to send an email to my inbox to test it out. I proceeded to create another servlet based on that 1st one, and for reasons I can't explain, the servlet won't compile.
I get this error.
cannot resolve symbol :
variable : RecipientType
location : java.lang.String
msg.setRecipient(Message.RecipientType.TO, to); I get the same error when I switch out setRecipient for addRecipient.
However, through further testing, I've found that not only does my 1st servlet still compile, but I'm also able to run the code from the 2nd servlet, successfully in a JSP page. This is driving me nuts...how could there be a problem compiling? There's no reason why one servlet compiles (with similar if not almost exactly the same code) and the other won't. Plus this runs fine in a JSP page...what's going on??? I've spent hours on this and I can't figure it out...please help, any input is appreciated.
Here is the JSP page that runs successfully :
<%@page import="java.io.*"%>
<%@page import="java.util.Properties"%>
<%@page import="javax.mail.*"%>
<%@page import="javax.mail.Message.RecipientType"%>
<%@page import="javax.mail.internet.*"%>
<%@page import="javax.servlet.*"%>
<%@page import="javax.servlet.http.*"%>
<%@page import="javax.naming.*"%>
<%@page import="javax.sql.*"%>
<%@page import="java.sql.*"%>
<%
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/myDB");
conn = ds.getConnection();
stmt = conn.createStatement();
//get the POP3 and SMTP property values from db
rs = stmt.executeQuery("Select Tech_Support_Email, POP3, SMTP from sitewide_info");
String hostemailaddress = "";
String POP3 = ""; //mail.smtp.host, this one 1st
String SMTP = ""; //smtp.stratos.net, this one 2nd
if(rs.next()) {
hostemailaddress = rs.getString(1);
POP3 = rs.getString(2);
SMTP = rs.getString(3);
// Specify the SMTP Host
Properties props = new Properties();
//POP3 = mail.smtp.host & SMTP = smtp.stratos.net - must be in this order
props.put(POP3, SMTP);
// Create a mail session
Session ssn = Session.getDefaultInstance(props, null);
ssn.setDebug(true);
String subject = "Testing out Email";
String body = "hello";
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rs = stmt.executeQuery("Select Customer_Name, Email_Address from customer_profiles where "
+"Customer_Number=1111");
String fromName = "";
String fromEmail = "";
if(rs.next()) {
fromName = rs.getString(1);
fromEmail = rs.getString(2);
InternetAddress from = new InternetAddress(fromEmail,fromName);
String toName = "Bob";
InternetAddress to = new InternetAddress(hostemailaddress,toName);
// Create the message
Message msg = new MimeMessage(ssn);
msg.setFrom(from);
msg.addRecipient(Message.RecipientType.TO, to);
msg.setSubject(subject);
msg.setContent(body, "text/html");
Transport.send(msg);
}//try
catch (MessagingException mex) {
mex.printStackTrace(); }
catch(Exception e) {}
finally {
try {
if (rs!=null) rs.close();
catch(SQLException e){}
try {
if (stmt!=null) stmt.close();
catch(SQLException e){}
try {
if (conn!=null) conn.close();
catch(SQLException e){}
}//finally
%>
Here's the servlet that won't compile :
package testing.servlets.email;
import java.io.*;
import java.util.Properties;
import javax.mail.*;
import javax.mail.Message.RecipientType;
import javax.mail.internet.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
public class MessageCenterServlet extends HttpServlet {
public Connection conn = null;
public Statement stmt = null;
public Statement stmt2 = null;
public ResultSet rs = null;
public ResultSet rss = null;
public PrintWriter out = null;
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
doPost(req,res);
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
try {
out = res.getWriter();
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");
DataSource ds =
(DataSource)ctx.lookup(
"java:comp/env/jdbc/myDB");
conn = ds.getConnection();
stmt = conn.createStatement();
stmt2 = conn.createStatement();
HttpSession session = req.getSession();
String Subject = (String)session.getAttribute("Subject");
String Message = (String)session.getAttribute("Message");
sendAnEmail(rs,stmt,Subject,Message,res);
}//try
catch (Exception e) { }
finally { cleanup(rs,rss,stmt,stmt2,conn); }
}//post
public void cleanup(ResultSet r, ResultSet rs, Statement s, Statement s2, Connection c){
try {
if (r!=null) r.close();
catch(SQLException e){}
try {
if (rs!=null) rs.close();
catch(SQLException e){}
try {
if (s!=null) s.close();
catch(SQLException e){}
try {
if (s2!=null) s2.close();
catch(SQLException e){}
try {
if (c!=null) c.close();
catch(SQLException e){}
}//cleanUp
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void sendAnEmail(ResultSet rs, Statement stmt, String Subject,String Message, HttpServletResponse res) {
try {
//get the POP3 and SMTP property values from db
rs = stmt.executeQuery("Select Tech_Support_Email, POP3, SMTP from sitewide_info");
String hostemailaddress = "";
String POP3 = "";
String SMTP = "";
if(rs.next()) {
hostemailaddress = rs.getString(1);
POP3 = rs.getString(2);
SMTP = rs.getString(3);
// Specify the SMTP Host
Properties props = new Properties();
props.put(POP3, SMTP);
// Create a mail session
Session ssn = Session.getDefaultInstance(props, null);
ssn.setDebug(true);
String subject = "Testing out Email";
String body = "hello";
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rs = stmt.executeQuery("Select Customer_Name, Email_Address from customer_profiles where "
+"Customer_Number=1111");
String fromName = "";
String fromEmail = "";
if(rs.next()) {
fromName = rs.getString(1);
fromEmail = rs.getString(2);
InternetAddress from = new InternetAddress(fromDealerEmail,fromDealerName);
String toName = "Bob";
InternetAddress to = new InternetAddress(hostemailaddress,toName);
// Create the message
Message msg = new MimeMessage(ssn);
msg.setFrom(from);
msg.setRecipient(Message.RecipientType.TO, to);
msg.setSubject(subject);
msg.setContent(body, "text/html");
Transport.send(msg);
}//try
catch (MessagingException mex) {
mex.printStackTrace(); }
catch(Exception e) {}
}//end
}//class -Love2Java
Edited by: Love2Java on Mar 11, 2008 9:15 PMI have similar problem
I have the below code in Eclipse and I was able to compile and run it and everything works fine...
but I have code over in Oracle Jdev and jdev is complaining that "Message.RecipientType.TO" is not found....
I do have all the jars in the class path.... can't figure out what's wrong
can some one plz help me out.
import java.util.Date;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.util.ByteArrayDataSource;
public void postMail( String recipients, String subject,
String message , String from) throws MessagingException
boolean debug = false;
//Set the host smtp address
Properties props = new Properties();
props.put("mail.smtp.host", "server");
props.put("mail.smtp.auth", "true");
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth);
session.setDebug(debug);
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
// Setting the Subject and Content Type
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
private class SMTPAuthenticator extends javax.mail.Authenticator
public PasswordAuthentication getPasswordAuthentication()
String username ="user";
String password = "pass";
return new PasswordAuthentication(username, password);
} -
AIR app won't compile with custom icons
My AIr app won't compile when I choose anything but the
default icons. I created 4 pngs in Photoshop and it gives me the
error: Useage error (incorrect arguments)
Any help? I've tried using only 1 icon, all 4, and no icons.
Only no icons works.You dont have to use the GUI to set it, you can use the air
appliation XML.
inside your air-app.xml file look for something like:
<icon>
<image128x128>icons/myIcon128.png</image128x128>
<image48x48>icons/myIcon48.png</image48x48>
<image32x32>icons/myIcon32.png</image32x32>
<image16x16>icons/myIcon16.png</image16x16>
</icon>
if its not there add it, but replace the myIcon128.png with
your 128 point png image etc.
also the above assumes your icons are in a folder called
"icons" in the same directory as your air file.
Hope it helps. -
When I was updating my ipod touch 4g 8g 4.3.3 the USB came out and now it just shows connect to itunes and when i try to update it comes with error 6. I do all of the help things and nothing happoned
First see if placing the iPod in Recovery Mode will allow a restore.
Next try DFU mode and restore.
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
If not successful then time for an appointment at the Genius Bar of an Apple store. You are not alone with this problem. -
My IPod nano (older version) is frozen, so I can't do anything, and all of the online "help" things say that the IPod icon should appear under "Devices" but it's not, and because the IPod's frozen... What should I do???
<What's the difference between a message and a question?>Which older model iPod Nano do you have? iPod Models
Read the user manual for a solution - iPod Manuals
A question ends with a "?" mark and a message ends with a "." period. -
I have wanted to update from 3.6.22, to 5.0.1, but can't do to the following reasons: I can't due to, too many things won't work with the version & will be disabled. They are: Microsoft. NET Framework Assistant 1.2.1, Iconix 3.90.1, HP Detect 1.0.5.1, Yahoo! Toolbar 2.3.5.201101200332202 (I don't care about Yahoo! Toolbar, because I don't use it!). As soon as these issues are fixed, I will be able to update, to the latest versions. These issues should be fixed & ready to work, before a new version is available. Thank you!
Try using this extension to force compatibility.
* https://addons.mozilla.org/en-US/firefox/addon/add-on-compatibility-reporter/
Check and tell if its working. -
JDeveloper 10.1.2.1 won't compile my code?
Hi,
I'm pretty new to JDeveloper, and Java in general.
I've just downloaded and tried to run JDeveloper 10g (10.1.2.1.0, Build 1913) and I've having problems.
When the application loads, I get a dialog message titled "Java Virtual Machine Launcher", with the message "Could not find the main class. Program will exit"
JDeveloper then finishes loading.
I've knocked up a quick JSP page, but it won't compile. I get the message "Internal compilation error, terminated with a fatal exception."
Also, I've notived that if I go to Project Properties and try to look at Profiles->Development->Libraries, JDeveloper throws a NullPointerException.
I've got JDeveloper 10.1.3 on my machine, and it has none of these problems?
After looking around on the web, I'm thinking it might be a CLASS_PATH problem, but how can I confirm this, and how can I fix it?
Any ideas on what is wrong would be appreciated?
Thanks
ThomThanks thahn.
That fixed the "Java Virtual Machine Launcher" error - I would never have thought spaces in the directory name could have caused this problem!
The other problems remain though, so I still can't compile any code.
Maybe you are looking for
-
TS1500 I followed the instructions but my phone is not showing up on the list
I'm trying to download pics from my phone I followed the directions that were given to disable a function in the control panel when I went I and found devices my phone is not showing up. It shows up in iTunes. What am I doing wrong?
-
Satellite P300-13J - S-Video output shows no picture
Hi, I need a little help here. I have P300D-13J and I bought it with OS Vista HP 32-bit. I have tested S-Video output few times after time I bought my computer and it worked fine,no problems. But,after a few months I needed S-Video output and I conne
-
How we can restrict generation of schedule line if Target Qty is reached.
Dear Gurus, What is the Exact Role of Target Qty in Scheduling Agreement. I have an issue here is even if the Target Qty is reached , system generates schedule lines through MRP. How we can restrict the generation of schedule line if Target Qty is re
-
I am trying to create a pattern swatch for this shape, but it doesn't seem to be possible to find the edge of this pattern. Take a look at the image I inserted, the colored boxes are the shape that will be repeated. The next picture is an example of
-
No active windows, no website, no pages no nothing in iWeb...
Oh my - just upgraded last night to Snow Leopard, afterwards i installed iLife 09. Then I worked 24 hours in iWeb created 2 sites, FTP' both sites to two servers, it was all perfect. Now to the problem. Right now when I start the program again - no w