Jump to content
xisto Community

vicky99

Members
  • Content Count

    54
  • Joined

  • Last visited

Everything posted by vicky99

  1. Thanks Pyost for your advice. I agree with you and I don’t provide games. Yet I cannot switch to Linux.. The reason is, 99% of people over here use windows. A few months back I bought Fedora Core 3.0 but I cannot use them in my café. Do you know about any Linux distribution which supports Microsoft Word or the complete Ms Office package? If so please tell me about it.
  2. Dear Friends Today I will show you how to create an executable jar file. I do not know whether this topic is introduced by any other member. Using this method one can build graphical user interface program with java which will behave similar to Executable files i.e., the program can be started with double clicks. It is an easy alternative. Otherwise to run a java program one has to run it through comand prompt(in windows) using java command or by creating java executalbes which are very difficult to make. So lets begin: Frist of all, we will create a simple java application using java foundation class popularly known as java Swing. Let the file name be JarExample. import java.awt.*;import java.awt.event.*;import javax.swing.*;public class JarExample { private static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Window"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel emptyLabel = new JLabel(""); emptyLabel.setPreferredSize(new Dimension(175, 100)); frame.getContentPane().add(emptyLabel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); }} Now compile the java file. JDK will produce two class files namely (a)JarExample.class ( JarExample$1.class. All the years we have been doing this.Your question might be what new? Its coming. Now we will create a Manifest File. If you have done java beans then you are quite familiar with the term. Let write our Manifest File:- The name of the file is :- jex.mf Manifest-Version: 1.0Main-Class: JarExampleWe are now ready to create our JAR file. create a folder, keep the class files (JarExample.class,JarExample$1.class) and the manifest file in that folder. Now open command prompt. Say for example your folder name is jar and you have kept it in C DRIVE. Now change directory using CD jar command. Now we will create jar file using following command. c:\jar>jar cfm jarex.jar jex.mf *.class It will create jarex.jar . I wish you will be able to create jar file using this method. If any problem occur feel free to ask me or you have any suggestion please tell me.
  3. Hello everybody I wrote this program a few months back when I wan learning JAVA.I haven't learned java yet though because its to vast. The program is console based. It uses the util package of java in a great way. It keeps record in a flat file. You should create a Data file called phone.dat in same folder where phone.java is kept. So here is the code:-(phone.java) import java .io .*; import java .util .*; import java.awt.event.*; public class phone { public void new_record() { String id,name,city,add,number,total,list; boolean bln=false; try { Properties pr=new Properties(); FileInputStream fin=new FileInputStream("phone.dat"); if(fin!=null) { pr.load(fin); } BufferedReader br1=new BufferedReader (new InputStreamReader(System.in)); FileOutputStream fout=new FileOutputStream("phone.dat"); for(;;) { System.out .println("Enter the 'ID', 'q' for quit:"); id=br1.readLine().toUpperCase(); bln=pr.containsKey(id); System.out .println("FLag"+bln); if(bln) { System.out.println("ID id already exists, Please Enter another ID:"); continue; } if((id.toUpperCase()).equals("Q")) break; System.out.println("enter name:"); name=br1.readLine().toUpperCase(); System.out.println("enter Phone number:"); number=br1.readLine().toUpperCase(); System.out.println("enter address:"); add=br1.readLine().toUpperCase(); System.out.println("enter city:"); city=br1.readLine().toUpperCase(); total=" Name="+name+","+"Phone no="+number+","+" Address="+add+","+" City="+city; total=total.toUpperCase(); pr.put(id,total); pr.store(fout,"My Telephone Book"); } fout.close(); } catch(Exception e) { System.out.println(e); } } public void display_record() { String id=""; String total=""; int x=1; try { FileInputStream fin=new FileInputStream("phone.dat"); Properties pr1=new Properties(); pr1.load(fin); Enumeration enum1=pr1.keys(); while(enum1.hasMoreElements()) { id=enum1.nextElement().toString(); total=pr1.get(id).toString(); StringTokenizer stk=new StringTokenizer(total,"=,"); System.out .println("RECORD ::"+x+"\n"); x++; while(stk.hasMoreTokens()) { String key=stk.nextToken(); String value=stk.nextToken(); System.out.println("\t"+key+"::\t\t::"+value); try { Thread.sleep(1500); } catch(Exception e){} } System.out.println(""); System.out.println(""); } fin.close(); } catch(Exception e){} } public void display_by_name() { String name="",id,total; String key[]=new String[4]; String value[]=new String[4]; int i=0; System.out.println("Enter Name For Searching Record :-"); try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); name=br.readLine().toUpperCase(); FileInputStream fin=new FileInputStream("phone.dat"); Properties pr1=new Properties(); pr1.load(fin); Enumeration enum1=pr1.keys(); while(enum1.hasMoreElements()) { id=enum1.nextElement().toString(); total=pr1.get(id).toString(); StringTokenizer stk=new StringTokenizer(total,"=,"); while(stk.hasMoreTokens()) { for(i=0;i<4;i++) { key[i]=stk.nextToken(); value[i]=stk.nextToken(); } if(value[0].equals(name)) { for(i=0;i<4;i++) { System.out.println("\t"+key[i]+":"+value[i]); try { Thread.sleep(1500); } catch(Exception e){} } } } System.out.println(""); } fin.close(); } catch(Exception e){ System.out.println(e); } } public void display_by_city() { String city="",id,total; String key2[]=new String[4]; String value2[]=new String[4]; int i=0; System.out.println("Enter City For Searching Record :-"); try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); city=br.readLine().toUpperCase(); FileInputStream fin=new FileInputStream("phone.dat"); Properties pr1=new Properties(); pr1.load(fin); Enumeration enum1=pr1.keys(); while(enum1.hasMoreElements()) { id=enum1.nextElement().toString(); total=pr1.get(id).toString(); StringTokenizer stk=new StringTokenizer(total,"=,"); while(stk.hasMoreTokens()) { key2[i]=stk.nextToken(); value2[i]=stk.nextToken(); // System.out.println("aaaaaaaaaaaaaaa"+value2[i]); if(i==3) { if(value2[i].equals(city)) { for(int j=0;j<4;j++) { System.out.println("\t"+key2[j]+":\t"+value2[j]); try { Thread.sleep(1500); } catch(Exception e){} } } } i++; if(i>3) i=0; } System.out.println(""); System.out.println(""); } fin.close(); } catch(Exception e){ System.out.println(e); } } public void display_record_first_letter() { String name="",id,total,str=""; String key2[]=new String[4]; String[] value2=new String[4]; int i=0; try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println(" Enter The First Letter Of any Name:"); name=br.readLine(); name=name.substring(0,1).toUpperCase(); FileInputStream fin=new FileInputStream("phone.dat"); Properties pr1=new Properties(); pr1.load(fin); Enumeration enum1=pr1.keys(); while(enum1.hasMoreElements()) { id=enum1.nextElement().toString(); total=pr1.get(id).toString(); StringTokenizer stk=new StringTokenizer(total,"=,"); while(stk.hasMoreTokens()) { for(i=0;i<4;i++) { key2[i]=stk.nextToken(); value2[i]=stk.nextToken(); } str=value2[0].substring(0,1); if(str.equals(name)) { for(i=0;i<4;i++) { System.out.println("\t"+key2[i]+":\t"+value2[i]); try { Thread.sleep(1500); } catch(Exception e){} } } } System.out.println(""); System.out.println(""); } fin.close(); } catch(Exception e){ System.out.println(e); } } public void replace_record() { String id,name,city,add,number,total,list; boolean bln=false; try { Properties pr=new Properties(); FileInputStream fin=new FileInputStream("phone.dat"); if(fin!=null) { pr.load(fin); } BufferedReader br1=new BufferedReader (new InputStreamReader(System.in)); FileOutputStream fout=new FileOutputStream("phone.dat"); for(;;) { System.out .println("Enter the 'ID', 'q' for quit:"); id=br1.readLine().toUpperCase(); if((id.toUpperCase()).equals("Q")) break; bln=pr.containsKey(id); if(bln) { System.out.println("ID id already exists, "); System.out.println("enter name:"); name=br1.readLine().toUpperCase(); System.out.println("enter Phone number:"); number=br1.readLine().toUpperCase(); System.out.println("enter address:"); add=br1.readLine().toUpperCase(); System.out.println("enter city:"); city=br1.readLine().toUpperCase(); total=" Name="+name+","+"Phone no="+number+","+" Address="+add+","+" City="+city; total=total.toUpperCase(); pr.put(id,total); pr.store(fout,"My Telephone Book"); } else { System.out.println("ID does'nt Exists, Please Enter A Valid ID:"); continue; } } pr.store(fout,"My Phone Book"); fout.close(); } catch(Exception e) { System.out.println(e); } } public void delete_record() { String id=""; boolean bln=false; try { Properties pr1=new Properties(); FileInputStream fin=new FileInputStream("phone.dat"); if(fin!=null) pr1.load(fin); BufferedReader br1=new BufferedReader (new InputStreamReader(System.in)); FileOutputStream fout=new FileOutputStream("phone.dat"); for(;;) { System.out .println("Enter the 'ID', 'q' for quit:"); id=br1.readLine().toUpperCase(); if((id.toUpperCase()).equals("Q")) break; bln=pr1.containsKey(id); if(bln) { System.out.println("ID exists :"); String str=pr1.remove(id).toString(); pr1.store(fout,"My Phone Book"); try { Thread.sleep(1500); } catch(Exception e){} System.out.println("Record deleted successfully"); } else { System.out.println("Enter Existing ID:"); pr1.store(fout,"My Phone Book"); } } pr1.store(fout,"My Phone Book"); fin.close(); fout.close(); } catch(Exception e) { System.out.println(e); } } public void menu() { char ch=30; char ch1=31; int l; for(int i=0;i<27;i++) { System.out.print(" "); } for(l=0;l<2;l++) { for(int j=0;j<38;j++) { System.out.print(ch); } System.out.println(""); for(int k=0;k<27;k++) { System.out.print(" "); } } System.out.print(ch); System.out.print(ch1); for(int i=0;i<34;i++) System.out.print(" "); System.out.print(ch); System.out.print(ch1); System.out.println(""); for(int i=0;i<27;i++) System.out.print(" "); System.out.print(ch); System.out.print(ch1+" "); System.out.print (" 1. Enter new Record: "); System.out.print(" "+ch); System.out.println(ch1+" "); for(int i=0;i<26;i++) System.out.print(" "); System.out.print(" "+ch1); System.out.print(ch+" "); System.out.print (" 2. Display All Record: "); System.out.print(" "+ch); System.out.println(ch1+" "); for(int i=0;i<26;i++) System.out.print(" "); System.out.print(" "+ch); System.out.print(ch1+" "); System.out.print (" 3. Search Record by name: "); System.out.print(" "+ch); System.out.println(ch1+" "); for(int i=0;i<26;i++) System.out.print(" "); System.out.print(" "+ch); System.out.print(ch1+" "); System.out.print (" 4. Search Record by city: "); System.out.print(" "+ch); System.out.println(ch1+" "); for(int i=0;i<26;i++) System.out.print(" "); System.out.print(" "+ch); System.out.print(ch1+" "); System.out.print (" 5. Search Record by 1st letter:"); System.out.print(" "+ch); System.out.println(ch1+" "); for(int i=0;i<26;i++) System.out.print(" "); System.out.print(" "+ch); System.out.print(ch1+" "); System.out .print(" 6. Replace Record: "); System.out.print(" "+ch); System.out.println(ch1+" "); for(int i=0;i<26;i++) System.out.print(" "); System.out.print(" "+ch); System.out.print(ch1+" "); System.out .print(" 7. Delete Record: "); System.out.print(" "+ch); System.out.println(ch1+" "); for(int i=0;i<26;i++) System.out.print(" "); System.out.print(" "+ch); System.out.print(ch1+" "); System.out .print(" 8. Exit: "); System.out.print(" "+ch); System.out.println(ch1+" "); for(int j=0;j<27;j++) System.out.print(" "); System.out.print(ch); System.out.print(ch1); for(int i=0;i<34;i++) System.out.print(" "); System.out.print(ch); System.out.print(ch1); System.out.println(""); for(int i=0;i<27;i++) System.out.print(" "); for(int i=0;i<38;i++) System.out.print(ch); System.out.println(""); for(int i=0;i<27;i++) System.out.print(" "); for(int i=0;i<38;i++) System.out.print(ch); } public static void main (String[] args) { phone cl=new phone(); BufferedReader br; for(;;) { try { cl.menu(); br=new BufferedReader (new InputStreamReader(System.in)); System.out.print(" &
  4. Dear MembersAs you all may be aware of the spywares, trojan horses,viruses which are troubling us. I have found out a descent way of protecting owr PC's from these harmful stufs. I run a cyber cafe and use windows xp home version. I am describing my way of protecting pc's:-1. Frist of all I have downloaded the windows XP service pack 2.2. Then I have downloaded Avg Free.3. Lastly I have downloaded Windows Defender.4. What I do is that, I have created two accounts in my computer. One Admin which have Administrator rights another guest account. I use the guest account to access internet as well as all other stufs. It helps to protect the pc in effective way. The Security Center of windows XP keep trak of Internal virus database on AVG. It alerts if the database is not updated. Then I downlaod the updates from AVG. Windows defender on the other hand provides run time protection. I guess I have made my point clear. If I have made any mistake please remind me of that.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.