JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

As Oracle keep improving Java, there are times when old classes and methods get replaced by newer better versions. The old versions are still there, so existing programs will continue to work, but they are marked as "deprecated" to tell programmers that they should replace or upgrade their code.
If you chose not to update your code, the constant warnings about using deprecated methods get very tedious, so you use the @suppresswarnings(deprecation) annotation to tell the compiler to stop bothering you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You write age as an int - a 32 bit binary value - it won't appear as text, just as 0-4 characters of garbage. You will need a binary file editor to see it properly.
For the eof, let's start with the info that Java already provides. In your catch block replace
System.out.println("The Exception Is : " +e);
with
e.printStackTrace();
that will give you a lot more info, including the exact line of your code where the error happened.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You create a grid layout 3x2 (6 components) then add 17 components to it.
For your eof error put some print statements into the read loop so you can see how many records it's reading, exactly where it hits eof etc.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here.

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's a fair point jwenting makes. You may find it easier to take up cardiac surgery or training fighter pilots . No, I'm not joking. Antivirus really is that hard.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'vce never got into anti-virus programming, so I'm sorry, you'll have to Google it yourself.
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You need to study how viruses work first, then look at how existing antivirus programs work. Its not easy, and needs a really deep understanding of the operating system.

In any case, Java is completely the wrong tool for this job. It's designed to be independent of any one operating system, and provides a protected enclosed vistual machine for your program. Your anitvirus will need to dig deep into the running operating system and file systems to look for hidden viruses. This is one of those rare cases where C (or maybe C++) is almost certainly your best option.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You are using a null layout manager for some reason - I suppose you are aware that this kills your portability - as soon as you run the code on any other machine with a different screen res / font size your text won't fit properly.

Anyway, getPreferredSize is called by layout managers to help lay out the screen as closely as possible to your requirements. With a null manager setting a preferred size is useless.
If you must use a null layout manager then you have to setBounds for every component.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That looks like some kind of server configuration problem???
But why are you running in server mode at all if you know the database is strictly local to your java application? Maybe you should be simply running Derby in embedded mode to avoid configuration and access problems?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Lines 8,9,10 are redundant - a single Education object contains values for degree, major and research, so all you need is a single instance of Education - let's call that variable "education" for the moment, and assume you initialise it with a complete instance of each Faculty's Education.
Now on line 51 you want to get the degree info from that Education.
No problem, the Education class has a suitable method, so you can just use that...
education.getDegree()

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I feel like I'm missing something here. What application logs 110 million events per day - do you work for Google?

stultuske commented: nah, just a company trying to screw with the NSA. can you imagine their analysts going over each and every line of that? :) +14
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That all looks sensible. In general you need to test for null first, then if it's not null you can test for an empty String - if you want to treat a blank string as being empty, then use trim() first.
getText returns a String, so the toString() is not needed.

if (btn[].getText() == null || btn[i].getText.trim().length() == 0) ...

It looks like the button text is something else, or you are in some context where that code isn't being executed. Try printing the text and the length of the text to see exactly what you've got.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The API shows the nuber of bits in a BigInteger to be both set and returned as an int, so the limit is 2^31 bits. That is part of the public API conrtract of the class, and is thus guaranteed. (It should also be within the memory size of a 2013 PC, if the VM memory size defaults are overidden).

Decimal 50 is less than 6 bits. 50! is certainly less than 50^50, which is less than 6*50 bits. Thus 50! is less than 300 bits - a trivial size for BigInteger.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes.

String's format method uses java.util.Formatter format specs (based on C's printf) to format data into strings with specified padding, decimal places etc etc etc

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's a nice demo of using a panel in a standard dialog. Thank you.

ps

 String password = new String(pf.getPassword());
 if (password.equals("admin")) {
   test = true;
 } else {
   test = false;
 }

OR just

String password = pf.getPassword();
test = password.equals("admin");
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The fully-qualified name of that class is java.util.Arrays so either use the fully qualified name, OR (and this is what people usually do) import it at the beginning of your program just like you did with ArrayList or Scanner
import java.util.Arrays;

ps all the java.lang classes (eg String) are automatically imported, no need for you to import those.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You don't need any kind of loop for this. Just declare the counter in the class and initialise it to zero. In your actionPerformed add 1 to it, then test to see if it's reached 6 yet.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

All you need is a counter in your DisplayButtonMessage class that you can increment inside the actionPerformed until it reaches 6. You need to declare it in the class so its value will persist between the sucessive calls to actionPerformed.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Use ProcessBuilder, not Runtime.exec

manel1989 commented: 5 +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No time to read your code now.. but...
You will learn an awful lot now from looking at the source code fr the actual API classes (eg how exceptions are handled in arrayCopy) - you should have a source.zip file in your jdk directory which contains it all. I recommend it as a general compendium of "best practice" java code, as well as examples of how best to solve specific problems.
add vs enque - if they are the same why not just use the "standard" Collection method names? If you want both then it's perfectly OK to have one as a one-line cover that just calls the other. The Vector class is a similar case...

ps: See also source code for Arrays.copyOf - ArrayStore is an unchekced exception that the VM will throw if the source and target arrays contain incompatible types, so you don't have to do anything to implement it

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, you can read or write the bytes of any file, Java doesn't care what the extension is. But you will need extra libraries to interpret the contents of MS office files, PDFs etc. It's easy to find them, just Google.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You only get one == on each run of the inner loop because that's the special case where j happens to be the same as i so you are comparing an array element with itself. Ie if j==i then array[i] == array[j]

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I have no major comments, but

There a some loops that could use the simpler enhanced for loop syntax, eg

for (int index = 0; index < data.length; index++) {
    dmap.put(data[index], 0.0);
}

vs

for (String s : data) {
    dmap.put(s, 0.0);
}

Instead of
for (Double s : dmap.values().toArray(new Double[dmap.size()])) {
you just need
for (Double s : dmap.values()) {
because the enhanced for can be used wuth any Collection.

The normal convention is that class names should start with a Capital letter.

I like your commenting style.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's exacty the same as addition except for the occasional minus sign instead of a plus sign. Just compare those two methods to see where sub deviates from the correct pattern in add

JeffGrigg commented: Yes. Exactly! +6
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

DaniWeb rules include: "Do post in full-sentence English"
It is OK if your English is not perfect.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That sounds like the whole thing to me! Nobody's going to do your homework for you, so the best thing is to get on with debugging your own code, as I suggested a couple of posts ago - ie find out whether its the calculation of the occurrences or the porinting that's worong.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How many times have we said this in the Java forum...
Never NEVER NEVER do this when writing new code:

} catch (Exception e) {
}

If/when there is an error you just told Java that you didn't want to know anything about it, and please discard the detailed error message that Java just created for you.
ALWAYS put an e.printStackTrace(); in your catch blocks until/unless you have a good reason to do something else.

There's no point anyone spending time on that code when there could be a perfectly good explanation that you have supressed.

stultuske commented: the most reliable reply to "no exceptions are thrown" that always seems to fit ... +14
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, Java may be overkill for this app, but if your intention is to learn/practice some Java then...
Start with the "business model" - the classes that will model the employees, sheets graded or whatever. The work upwards from there to the user interface, and downwards to the database (JavaDB or whatever)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

JTable has methods to addColumn and removeColumn which affect the visible table (but do not change the underlying table model).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

YOu can use a CardLayout to swap between different JPanels in a JFrame

http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html#card

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, here's little runnable demo code that wants you to keep typing lines of anything. If you don't enter a line for 2 secs it times out and exits.
If you read this code, in conjunction with the API doc, you should be able to write a version that fits your requirement

        Scanner scan = new Scanner(System.in);
        java.util.Timer timer = null;
        System.out.println("keep entering lines...");
        do {
            if (timer != null) timer.cancel();
            java.util.TimerTask task= new java.util.TimerTask() {
                public void run() {
                    System.out.println("You timed out");
                    System.exit(0);
                }
            };
            timer = new java.util.Timer();
            timer.schedule(task, 2000);
        } while (scan.nextLine().length() != 0);
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Not quite. "\x" is not an escape in Java. You get the 4 \ because of the combination of Java and regex. \ is an escape char in both Java and regex, so if you want a literal \ in a regex you have to code it as \\. But then if that's a Java string you have to code each of those \ as \\, giving \\\\.
so
\\\\ in a Java regex string is \\ in the regex, which is a literal regex \

(That's why I have a "\\\\x" in my 2-line solution above - the first String in a replaceAll is a regex.)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

How are you running the program? In particular, if you run it with javaw.exe then there is no console. If so, run it with java.exe instead.

<M/> commented: :) +8
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here.

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I think you should try to compile and execute that code before assuming you have finished!

JeffGrigg commented: Yes. And we know why. ;-> +6
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can use a java.util.Timer
When you receive anything from the user, cancel any existing Timer and start a new one with a 2 hour delay.
If the Timer's TimerTask ever runs it means 2 hours have expired without any input, so it can close the connection.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can sleep the current thread by using Thread's sleep method
http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html#sleep%28long%29

ps: I assume you know that your constructor will loop recursively until you run out of memory?

JeffGrigg commented: Direct, simple and correct. Thanks! +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You don't have any value for teamName - it's declared but never initialised. Presumably you intend at some stage to read it from the scanner, but for step-by-step testing (which, by the way is a VERY good thing to do) you could simply give it some temporary sensible value.

Once you've fixed that you need to look at why you pass teamName as a String, but the Team class thinks it should be an instance of Game.

ps: next time please post the complete text of the error message so we don't have to guess

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

bob.henry: The first thing to learn here is "never just copy code that someone else has given you". No matter how well-intended they may be, and no matter how good the code is, you won't learn much.
Maybe phorce could use his/her time now to help you learn how to debug a loop - that way you will (a) gain an essential skill and (b) fix your problem.

In the meantime - here's your lines 24-27 correctly layed out...

while(ans.equals("y")){
   numberGenerator();
   System.out.println("\nI (etc etc)");
}

Can you see theproblem there?

ps phorce: "The code was written badly, and, is complicated to read and understand. You should re-write this, changing the logic of the program and the structure." Do you really think that's helpful? Just telling someone their code is bad and telling them to change it is demoralising, maybe insulting, and gives zero help. If you want to make comments like that then explain how and why it's bad, and how to change that to make it better (maybe with a short example - not a complete re-write). Please remember we're not here to do people's homework, we're here to help them become better programmers.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Continuing the fun here: If your three enums have the same methods then you can define your enums as implementing an interface that defines those methods, eg

    interface IFace {
        String getString();
    }

    enum E1 implements IFace {
        A, B, C;
        public String getString() {
            return "E1." + name()
        }
    }

    enum E2 implements IFace {
        E, F, G;
        public String getString() {
            return "E2." + name()
        }
    }

Now you can define your combo box in terms of that interface, add any members of any enum that implements the interface, and directly call the interface's methods on the combobox items without any casting etc...

        JComboBox<IFace> e = new JComboBox<>();
        e.addItem(E1.A);
        e.addItem(E2.E);
        ...
        System.out.println(e.getItemAt(0).getString()); // works
        System.out.println(e.getItemAt(1).getString()); // works
<M/> commented: :) +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

pack() lays out all the components you have added according to the layout manager settings. You need to call it after doing anything that affects the layout, eg adding components. It makes the JFrame just big enough, and ignores any setSize you previously executed. setMinimumSize does what you expect, and mostly seems to work with GridBagLayout.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Here's a version of your code that illustrates all the above (plus some shorter technique for using GBCs)

     void initBag() {

        JFrame jFrm = new JFrame("grid Bag");
        jFrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JLabel label1 = new JLabel("Name");
        JLabel label2 = new JLabel("EMail");
        JLabel label3 = new JLabel("Contact No");
        JLabel label4 = new JLabel("Code No");

        JTextField text1 = new JTextField(10);
        JTextField text2 = new JTextField(10);
        JTextField text3 = new JTextField(5);
        JTextField text4 = new JTextField(8);

        JPanel panel = new JPanel();
        panel.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        // gbc.gridx = GridBagConstraints.RELATIVE; // not needed (default)
        // places components one after another - the default for gridx and gridy

        gbc.gridy = 0;
        panel.add(label1, gbc);
        panel.add(label2, gbc);
        panel.add(label3, gbc);
        panel.add(label4, gbc);

        gbc.gridy = 1;
        panel.add(text1, gbc);
        panel.add(text2, gbc);
        panel.add(text3, gbc);
        panel.add(text4, gbc);

        jFrm.setMinimumSize(new Dimension(500, 400));
        jFrm.add(panel, BorderLayout.PAGE_START);
        jFrm.pack();
        jFrm.setLocationRelativeTo(null);
        jFrm.setVisible(true);
    }
<M/> commented: :) +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Null layout is a TERRIBLE idea. It guarantees that your UI will not fit properly when running on any system that has a different pixel density or fonts, and cannot respond to window resizes properly.
Group layout with a GUI builder is a reasonable option, but falls down as soon as you have any kind of dynamic content (variable number of components etc).
I'm going to stick with my preferred approach of using GridBagLayout so I have personal direct control over the whole thing, including its exact behaviour on resizes etc.
But each to his own...

ps Murali: don't forgat to pack() after adding (or removing) components so the layout manager can do its job.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Lines 13-15 look like a method definition, but they are right in the middle of an if inside another method. That has baffled the compiler and is the source of all three errors. Remember you can only define a method inside a class but outside any other method definitons. (OK, not exactly true, but we can talk about anonymous inner classes another time.)
You will find it much easier to get your brackets right if you indent your code (or use an editor that does it for you).

ps Welcome to DaniWeb! Please take a moment to check the site rules, and please mark your threads "solved" when you have finished.