Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 41

Thread: Help me,Please

  1. #21
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default thanks to everyone.

    Ok,thanks to everyone of you.I have completed my project.

    Here is onle the code by which I have compared two textfiles.........


    Java Code:
         List<String> firstList;
         List<String> secondList;
         int i;
    try{
    
    BufferedReader za=new BufferedReader(new FileReader("C:/MySQl.txt"));
    BufferedReader ta=new BufferedReader(new FileReader("C:/yours.txt"));
    
    String at,bt;
    String stk="",sb="";
    String[] firstArray;
    String[] secondArray;
    
    
    while((at=za.readLine())!=null)
         stk+=at;
    
    
    firstArray = stk.split("\\.");
    firstList = Arrays.asList(firstArray);
    
    
    
    while((bt=ta.readLine())!=null)
         sb+=bt;
    
    
    secondArray = sb.split("\\.");
    secondList = Arrays.asList(secondArray);
    
    
    int size[];
     size=new int[secondArray.length];
    
    
    for(i=0;i<secondArray.length;i++)
          size[i]=0;
    
    
    ///////////////comparing/////////////////
    
    
    for(i=0;i<secondArray.length;i++)
       for(int j=0;j<firstArray.length;j++)
             if(secondArray[i].equals(firstArray[j]))
                                size[i]++;
    Last edited by Eranga; 07-07-2010 at 04:20 AM. Reason: code tags added

  2. #22
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Well done on completing your project, quick tip to improve again, do no use non descriptive variable names for you're variables e.g. try to avoid

    Java Code:
    BufferedReader za=new BufferedReader(new FileReader("C:/MySQl.txt"));
    BufferedReader ta=new BufferedReader(new FileReader("C:/yours.txt"));
    
    String at,bt;
    String stk="",sb="";

  3. #23
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    @OP, Please use code tags when you are posting code segments here in the forum. Unformated codes are really hard to read. If you don't know how to do that check my signature.

  4. #24
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by al_Marshy_1981 View Post
    Well done on completing your project, quick tip to improve again, do no use non descriptive variable names for you're variables e.g. try to avoid
    Naming conventions are playing a major role in any programming language.

  5. #25
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default "Could not find the main class.program will exit."

    Now I am trying to make a jar file of it.I know that when running it on netbeans then there is automatically created a jar file of it.I found that.but When I am double clicking on it,it shows that,
    "Could not find the main class.program will exit."

    What is the problem??

  6. #26
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Please post the full text of the error message here. Don't edit it and leave out parts of it.

  7. #27
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    When I am double-clicking,a window is being visible with the that message only.

    "Could not find main class.Programs will exit"

  8. #28
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    To get better error message, open a command prompt window, change to the folder with the jar file and enter:

    java -jar YOURJARFILENAMEHERE.jar

    Copy and paste the contents of the command prompt window here.

    The problem could be that the manifest file does not have a correct Main-Class: entry or the main class is in the wrong folder in the jar or the main class is missing from the jar.

  9. #29
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    after executation of this line java -jar Compare.jar,

    //Exception in thread "main" java.lang.NoClassDefFoundError:Compare/java//

    Would u mind,please tell me that what should I do now?

  10. #30
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Look in the jar file at the manifest file. See what the Main-Class: is.
    It should refer to a class file (without the .class extension).

    Your error message is weird: java.lang.NoClassDefFoundError:Compare/java//
    I don't know where the / and // come from. I suppose you typed it from memory vs doing a copy and paste.
    Last edited by Norm; 07-07-2010 at 06:33 PM.

  11. #31
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    Norm,
    Now it is working in command prompt with this given below,

    java -jar YOURJARFILENAMEHERE.jar

    But after double-clicking same as before.

    There is one file named manifest.mf
    But What should I do??

  12. #32
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    If it works when you manually use the java -jar ... command in a command prompt and gives you an error when you double click on it, then their could be a problem in the extension association table in the registry. Look at the command line associated with jar files by doing:
    Open Windows Explorer
    Click on Tools menu
    Click on Folder Options
    Select File Types tab
    Scroll down in the "Registered file types:" list until you see an entry for JAR.
    Select the JAR entry.
    Click the Advanced button
    In the Edit File Type window scroll down the list of Actions until you see the one in bold.
    Select the bold one
    Click the Edit button
    Select, Copy and paste here what is in the "Application used to perform action:" window.

    Be careful not to change anything and Cancel your way out of the open windows.

  13. #33
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    Norm,
    May be I am disturbing you too much.I have done as you said.I also included Main-Class: classname
    into menifest.But still same problem.Double-clicking?

  14. #34
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    I have done as you said.
    Where is the command line for the jar file extension?

    If your code executes correctly when you go to the command prompt and enter:
    java -jar YOURJARFILENAME.jar
    then the manifest file must be OK.

    If the code does not execute when you double click on the same jar file referenced above, then there is a problem in the OS that it is NOT using the proper command line to execute the jar file.

  15. #35
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    Thanks to everyone.Double clicking the Jar file,this can not access the database.What should I do??

    Actually,in my project I had to access MySQL database.But with JAR file I don't get datas from DATABASE,Why??

  16. #36
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    But with JAR file I don't get datas from DATABASE
    Add some code to your program to output debug information.
    Be sure to use printStackTrace() in ALL catch(Exception) blocks.
    Run the program in a command prompt, copy and paste the output here

  17. #37
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    NORM,Now it's working.Anywhere in the folders,with doubleclick,it is working also accessing DATABASE.

    [COLOR="Blue"]Open Windows Explorer
    Click on Tools menu
    Click on Folder Options
    Select File Types tab
    Scroll down in the "Registered file types:" list until you see an entry for JAR.
    Select the JAR entry.
    Click the Advanced button
    In the Edit File Type window scroll down the list of Actions until you see the one in bold.
    Select the bold one
    Click the Edit button
    Select, Copy and paste here what is in the "Application used to perform action:" window.
    [/COLOR]


    Application used to perform action:

    In this place there was
    "C:\Program Files\Java\jre1.6.0_01\bin\javaw.exe" -jar "%1" %*
    I have changed it to
    "C:\Program Files\Java\jdk1.6.0_01\bin\javaw.exe" -jar "%1" %*

    Thanks to helping me.I thing we will continue this job.

  18. #38
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    If the path to the javaw command did not exist, then nothing would happen when you double clicked on the jar file.

  19. #39
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by UJJAL DHAR View Post
    Now I am trying to make a jar file of it.I know that when running it on netbeans then there is automatically created a jar file of it.I found that.but When I am double clicking on it,it shows that,
    "Could not find the main class.program will exit."

    What is the problem??
    If you have multiple main classes in your project, then before build the JAR file in NetBeans you must define the main class from the project properties window. Did you do that?

  20. #40
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    Now I want to do some new one.When I cursor on the 'X' button of window,it is being closed.But I want that when i will fulfill some condition,then it will be closed,otherwise not.How it can be possible?

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •