Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Working on Win 7 and not on XP

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Working on Win 7 and not on XP

    Hi i have a piece of code thats working on Win 7 but not on XP
    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


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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?

  3. #3
    Junior Member
    Join Date
    May 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

Similar Threads

  1. Why isn't this working?
    By javapenguin in forum What's Wrong With My Code?
    Replies: 14
    Last Post: January 21st, 2011, 04:08 PM
  2. Complier not working
    By Benderman in forum The Cafe
    Replies: 3
    Last Post: January 9th, 2011, 06:05 PM
  3. [SOLVED] CoreJavaExample Not Working
    By prasana in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 12th, 2010, 12:23 PM
  4. Cannot seem to get this working
    By OttawaGuy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 28th, 2010, 04:41 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM