Working on Win 7 and not on XP
Hi i have a piece of code thats working on Win 7 but not on XP
Code :
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class findclasses {
static int module = 1;
public String find1(String file) throws Exception {
String classname = "";
String ccc = "";
String s1 = "", name = " ";
String[] s = file.split("\\\\");
int i = 0;
for (i = 0; i < s.length - 2; i++) {
s1 += s[i] + "\\";
}
s1 += s[i];
String path = s1;
String filename = s[i + 1];
boolean check = false;
FileReader fis = new FileReader(file);
BufferedReader b1 = new BufferedReader(fis);
while ((s1 = b1.readLine()) != null) {
insertclass ic = new insertclass();
if ((check && s1.length() >= 2)
|| (s1.length() >= 2 && s1.substring(0, 2).equals("/*"))) { check = true;
if (!(s1.substring(s1.length() - 2, s1.length()).equals("*/"))) {
continue;
} else {
check = false;
}
} else {
if (s1.length() >= 1 && !(s1.substring(0, 1).equals("/"))) {
Pattern p = Pattern.compile("[\\w]+");
Matcher m = p.matcher(s1);
while (m.find()) {
if ((m.group().equals("class"))) {
if (m.find()) {
String strTemp = "class" + " " + m.group();
try {
Class<?> c=Class.forName(m.group());
System.out.println("Shaumux: "+c);
classname += "$" + strTemp;
ic.getinput(path, module, filename, m.group(), "class");
} catch (Exception e) {
System.out.println(m.group());
}
}
}
}
}
}
}
module++;
return classname;
}
}
The problem code is
Class<?> c=Class.forName(m.group());
Runs fine on win 7 but on XP it says class not found. and raises an exception.
I can't figure out the problem
Any help?
Thanks
Re: Working on Win 7 and not on XP
1. Does the compiled class file actually exist?
2. Does your JVM know where to find that class? Compare your folder structure and ClassPath
3. Are you using the exact same inputs?
4. Do you have the same Java versions (may or may not matter, the hope is that it doesn't)? What class are you looking for, btw?
Re: Working on Win 7 and not on XP
Thanks
The first point was the problem.
The compiled classes didn't exist and i totally forgot about them and continually kept searching the code.