My aplication doesn't work after update jre1.5.0.11 to 1.6.0.1
I updated java from jre 1.5.0.11 to jre1.6.01 and now my aplication returns 14 errors. Some of the errors are :
Canno find symbol
symbol:class regex.
Then I deleted that update but it still doesn't work. Don't know what to do. Do I need to reinstall all java package?
[330 byte] By [
Zdravkoa] at [2007-11-27 3:58:23]

I don't think it can ever have worked. Assuming that you wrote the program then YOU will know which package class regex is in (it is not part of 1.5 or 1.6) so YOU must have setup the classpath under 1.5 and it will be just the same under 1.6.
I'm confused now! Regex is in C:\Program Files\Java\jdk1.5.0_11\src.zip Exactly in java/util/regex. I imported it, but got the same
> I'm confused now! Regex is in C:\Program> Files\Java\jdk1.5.0_11\src.zip Exactly in> java/util/regex. I imported it, but got the sameThere is no class regex in java.util.regex so either your code never worked OR you have mis-reported the error message.
The 1. error is Contact.java:17: cannot find symbol
symbol : class Regex
loation: class Contact
Regex r=new Regex();
The class regex is made by me. I should tell that the my class is regex which importsjava.util.regex: import java.util.regex.*;
public class Regex {
//ulazne varijable
String patStr ="(\\+)*(385|0385|00385)*(\\s)*(\\W)*(0)*(\\W)*(\\s|\\d)*(\\d{3})(\\s|\\d|-)(\\d{3})(\\s|\\d)(\\D)";
String tekst="pope:098 9523 616 mob";
//izlazne varijabe
int start=-1;
int end=-1;
public void find() {
// Compile regular expression
try{
//Pattern p = Pattern.compile(patStr);
//Pattern p = Pattern.compile(patStr, Pattern.CASE_INSENSITIVE);
Pattern p = Pattern.compile(patStr, Pattern.UNICODE_CASE);
Matcher m = p.matcher(tekst);
boolean matchFound = m.find();// true
//System.out.println(matchFound);
if(matchFound==true){
// Get matching string
String match = m.group(); // b
// Get indices of matching string
start = m.start();// 2
end = m.end();// 3
// the end is index of the last matching character + 1
//System.out.println("start= "+start+" end= " + end);
}
else start=-1;
}catch(PatternSyntaxException pse){
System.out.println(pse.getMessage());
}
}
}
So you mis-reported the error!The compilation of the code that has the expressionRegex r=new Regex(); does not have the class path set so that it can find class Regex.
Excuse me if I ask a stupid question: how to set class path. The file Contact.java (where the class is initialized )and Regex.java are in the same directory.
> Excuse me if I ask a stupid question: how to set> class path. The file Contact.java (where the class is> initialized )and Regex.java are in the same directory.Those are source code files, not classes
The same way you did on 1.5 . Probably something likejavac-classpath.*.java
>I'm confused now! Regex is in C:\Program Files\Java\jdk1.5.0_11\src.zip >Exactly in java/util/regex. I imported it, but got the sameuse C:\Program Files\Java\jdk1.5.0_11\jre\lib\rt.jar instead.
Sorry I' ve written rong Contact. class and Regex.class!
But why I don't need to set class path when I compile some other of my classes for example Mysql.class
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;
public class Mysql {
String email; // ulazna varijabla
String tel;// ulazna varijabla
String mob=null;
String place=null;
int reg=0;
String link=null;
float price=0;
String pic1;
String pic2;
String pic3;
public void save (){
//email="zdravko.eskinja@hrbi.hr";//za testne svrhe
//email="nikola.mikulic@hrbi.hr";// za testne svrhe
//tel=" 091 534 9329";
//id=5; //indeks podatka za testne svrhe
int InIt=0;// flag oznacava da li je upisivanje uspjelo ili vec postoji neki takava email
int id;// varijablakoja se sama postavlja - indeks podataka
try {
// The newInstance() call is a work around for some
// broken Java implementations
Class.forName("com.mysql.jdbc.Driver");
} catch (Exception ex) {
// handle the error
System.out.println("ForNameException: " + ex.getMessage());
}
Connection conn = null;
try {
conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/apartmani" ,"root","10000000");
// Do something with the Connection
Statement stmt = conn.createStatement();
ResultSet rs;
/* rs = stmt.executeQuery("select email from people where id=1");
while ( rs.next() ) {
String Pemail = rs.getString("email");
System.out.println(Pemail);
}
*/
rs=stmt.executeQuery("select max(id) from people"); // trazim redni broj zadnjeg podatka
Integer MaxValue = new Integer(-1);
if(rs.next()){
MaxValue = rs.getInt(1);
}
id=MaxValue+1;
PreparedStatement stmt2 = null;
stmt2 = conn.prepareStatement("INSERT INTO people VALUES ('"+id+"','"+email+"','"+tel+"',NULL,NULL,'"+reg+"',NULL,'"+price+"',?,?,?)");
stmt2.setString(1, pic1);
stmt2.setString(2, pic2);
stmt2.setString(3, pic3);
stmt2.executeUpdate();
ResultSet r2 = stmt2.getResultSet();
//stmt.executeUpdate("INSERT INTO people VALUES('"+id+"',+'"+email+"','"+tel+"',NULL,NULL,0,NULL,0,NULL,'"+pic2+"',NULL)");
conn.close();
InIt=1; //uspjelo je upisivanje u tablicu
System.out.println("InIt = " + InIt);
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
} //zavr歛va metoda
} //zavr歛va klasa
are using a java IDE or coding manually ?
> >I'm confused now! Regex is in C:\Program
> Files\Java\jdk1.5.0_11\src.zip >Exactly in
> java/util/regex. I imported it, but got the same
>
> use C:\Program
> Files\Java\jdk1.5.0_11\jre\lib\rt.jar
instead.
There is never (well almost never) any need to specify the rt.jar to use since both java and javac pick it up automatically.
@sabre150 : All right. What I meant is to use rt.jar and not src.zip.@Zdravko: if you compile your java files using the command given by sabre150, what happens ?
which command.. I think there is no need to set path.. they are in the sam directoryI'm quite sure that it worked before my java update, so my only idea is to reinstall jre, jdk and all connected to java.
> which command..
Reply #8!
> I think there is no need to set
> path.. they are in the sam directory
But it won't hurt to try it will it?
> I'm quite sure that it worked before my java update,
I'm not because nothing should change expect the PATH (not the classpath) to the jre/bin directory.
> so my only idea is to reinstall jre, jdk and all
> connected to java.
Which is silly!
Ok then I'll first do as you say
You updated from 1.5 to 1.6.There is no longer a 1.5 jdk, right?Have you rebooted your windows box since?
Yes I restarted it if you mean that.For Sabre150:Wrote this:javac -classpath C:\projects\aplication\Frita1005\Contact.java Contact .javaGot the same
Also now is jre 1.5.0.11, I deleted update
> Yes I restarted it if you mean that.
> For Sabre150:
> Wrote this:
> > javac -classpath
> C:\projects\aplication\Frita1005\Contact.java Contact
> .java
>
> Got the same
THAT IS NOT WHAT I SAID TO DO!
I give up. You obviously don't listen.
Sorry I didn't understand. How to set the path then
> Sorry I didn't understand. How to set the path thenWhat the **** did I say in #8!
>javac -classpath C:\projects\aplication\Frita1005\Contact.java Contact .java
Sir,
Do the following :
1 - open MS-DOS
2 - type : cd C:\projects\aplication\Frita1005\ then press [Enter]
3 - compile like the following: javac -classpath . *.java
4 - tell us what happens plz
Good try java_2006 but the OP won't do it.
Copy of Mysql.java:7: class Mysql is public, should be declared in a file named Mysql.java
public class Mysql {
Mysql.java:7: duplicate class: Mysql
public class Mysql {
Note: Glavni.java uses or overrides a deprecated API.
Note: Recompile with -Xlint: deprecation for details.
2 errors
You have two copies of your java source in the same directory or in the path.
remove Copy of Mysql.java file and try again
You really should looks closely at error messages. You have a file called "Copy of Mysql.java" in your directory.
Tried againNote: Glavni.java uses or overrides a deprecated API.Note: Recompile with -Xlint: deprecation for details.
Which is just a warning and can be ignored.
and when I compile Contact.java I got the same
> and when I compile Contact.java I got the sameJesus! Ignore the ******* warning!
If you'd like to avoid such warning, compile your java sources like the following: javac -Xlint -classpath . *.java
not that the sameI got 14 errors like can't find symbolsymbol class regex
same thing like in beginning
> not that the same
> I got 14 errors like can't find symbol
> symbol class regex
If you only got warnings when you compiled with
javac -classpath . *.java
then all your java classes compiled OK.
What command are you typing and what is the full error set?
C:\projects\aplication\Frita1005>javac Contact.java
Contact.java:17: cannot find symbol
symbol : class Regex
location: class Contact
Regex r=new Regex();
^
Contact.java:17: cannot find symbol
symbol : class Regex
location: class Contact
Regex r=new Regex();
^
Contact.java:105: operator + cannot be applied to Regex.start,int
phone =LineBuff.substring(r.start+1,r.en
d-1);//izdvajam adresu i smje
stam je u zasebni string
^
Contact.java:105: cannot find symbol
symbol : method substring(<nulltype>,int)
location: class java.lang.String
phone =LineBuff.substring(r.start+1,r.en
d-1);//izdvajam adresu i smje
stam je u zasebni string
^
Contact.java:139: operator + cannot be applied to Regex.start,int
pic=line.substring(r.start+9,r.end-1);
^
Contact.java:139: cannot find symbol
symbol : method substring(<nulltype>,int)
location: class java.lang.String
pic=line.substring(r.start+9,r.end-1);
^
Contact.java:157: operator + cannot be applied to Regex.start,int
sirina=whb.substring(r.start+7,r.end);
^
Contact.java:166: operator + cannot be applied to Regex.start,int
visina=whb.substring(r.start+8,r.end);
^
Contact.java:204: operator + cannot be applied to Regex.start,int
Sflag+=(r.start+1);
^
Contact.java:204: inconvertible types
found: <nulltype>
required: int
Sflag+=(r.start+1);
^
Contact.java:205: operator + cannot be applied to Regex.start,int
PomT=PomT.substring(r.start+1);
^
Contact.java:205: cannot find symbol
symbol : method substring(<nulltype>)
location: class java.lang.String
PomT=PomT.substring(r.start+1);
^
Contact.java:292: cannot find symbol
symbol : class Mysql
location: class Contact
Mysql DB=new Mysql();
^
Contact.java:292: cannot find symbol
symbol : class Mysql
location: class Contact
Mysql DB=new Mysql();
^
14 errors
C:\projects\aplication\Frita1005>
Your really don't listen do you! Why do you think we said usejava -classpath . *.java
I listenn, but don't understand. What I messed up now?
> I listenn, but don't understand. What I messed up now?
To break it down
1) javac says compile
2) -classpath .says use this directory (that is what the . signifies) to find any classes that are not system classes
3) *.javaAll my java files in this directory.
Thank you guys, but I'm obviously to dumb to get it. I see that generated .class files but when I run class java which uses method from Contact I get this:
C:\projects\aplication\Frita1005>java Testing
Exception in thread "main" java.lang.NoClassDefFoundError: Testing
C:\projects\aplication\Frita1005>
No hard feelings, You are the best, I appreciate your effort.
Wow!java -classpath .Testingbut I suspect you will have to add the jdbc driver jar to the classpath.
I lost my nerves. I' ll try tomorrow!
I tried yesterday.. It really works! Thank you guys. Thanks for potience with me. I couldn't understand that now in jre 1.6.01 is all the same except the difference in puting -classpath . after javac or java.