I have a java project in Eclipse. I make changes to this project from different computers. I think this is a good opportunity to learn and practice some source control. Is there a source control system which will allow me to do this very easily ? How about Git ? Any outline of the main steps needed to setup this thing with Git, preferably within eclipse itself ? I don't need each and every step to prepare the whole system. I only need the main steps like - download and install git on both machines, rent a server and create a repo on it, grant both computers access to the server etc.
I notice when I look to download library jars, I keep ending up at Maven Repository: Search/Browse/Explore. I wonder is this really the de-facto place to download jars for java libraries? Right now I want to use the apache commons net library in order to build an imap server. And I find myself again mvnrepository:Is this where I should be downloading jar files?
While going through stpring batch,every where there uses pom.xml. But in my office maven repo is blocked. How to get the jar files .
Is there any way to run pom.xml online and download required jar to my local drive. or how to run a pom.xml file after setting maven, I had done all the same but some unknown issues.
I'm trying to retrieve information from a json repository stored online. I have so far setup my code to create the string that could be used as the url. What I'm not sure about is how you setup a Json Parser?
- Would you recommend I use a library? I hear google-gson is meant to be good?
- How easy is it to convert a string into a URL? I assumed that this would be good enough
I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
how to create a tree data structure in java.I tried with a class consisting of node field and arraylist child nodes. but it does not satisfy the requirement.the requirement is that,
I'm getting a DOMException, "HIERARCHY_REQUEST_ERR". I know that the problem is from the following code towards the bottom in my function, but I don't know how to deal with it. When I get rid of doc.appendChild(staff);, I get rid of the problem, but it obviously doesn't add the new entry to my root element.
Element staff = doc.createElement("Staff"); doc.appendChild(staff);
I want to create a TASK MANAGER for windows OS using java. Of course i am not expecting any code snippets, that is, what are the classes to be included and moreover HOW to do it.
Anyway I am creating a game for my A2 coursework, most commonly known as Checkers. I have completed my code and everything works as I had planned except that the CheckerBoard itself as well as the checkerpieces do not appear to be showing.
The section of were my board should be present is just a black space. Although my board does not appear to be displaying, all of the actions I perform on it such as clicking certain section produces the planned response, and although I've checked through my code I cannot work out what I've done wrong.
CheckerBoard content = new CheckerBoard(); // Sets the CheckerBoard values into the content to be used in the next line application.setContentPane(content); // Container holds the values together, Content pane of the CheckerBoard application.pack(); // Use preferred size of content to set size of application. Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); application.setLocation( (screensize.width - application.getWidth())/2, (screensize.height - application.getHeight())/2 );
[Code] ....
I have noticed is that within the BoardComplete(), if you change the setBackground(Color.BLACK) to WHITE, it will change the colour of the section to white, but the checkboard is still unshown.
I'm finding common elements in a collection of arrays. This is my code so far.
import java.util.ArrayList; import java.util.List; public class CommonElements //< T extends Comparable<T> > { Comparable[] comparable; Comparable[] tempArr; Comparable[] tempArr1; Comparable[] newArray = new Comparable[tempArr.length]; int comparisonCount;
[code]....
I'm using this method to sort through my array. The method accepts a collection of arrays (of varying length and of any type) as input, the algorithm input should be no greater than n(k-1). I know I can solve it using a quadratic algorithm, but it won't meet the requirement of the assignment. I did have an idea of storing all my algorithm in one giant array. After storing as one giant array I was going to sort it. After sorting I was going to compare each array side by side and see if they are the same. Here is note my teacher provided.
Note About Testing You will need to develop several sets of test collections for testing your algorithm. The grading rubric mentions covering the case where all the test collections have the same length, as well as covering the case where the test collections are of different lengths. You will also need to think about what constitutes the worst case scenario for this algorithm, since only that scenario will make your analysis of total comparisons performed a meaningful one. You can use the formulas in the grading rubric to tell you how many comparisons you should expect in the quadratic and linear cases. For example, if you have 5 total collections (1 query collection and 4 test collections), each of which contains 10 elements, the total number of comparisons performed in the worst case should be: (k - 1)N2, which for k = 10 and N = 10 is: (5 - 1)102, or 400 comparisons. For the linear algorithm, you should only have N*(k - 1), which is 10*(5 - 1), or 40 comparisons.
Here is Q/A that my teacher provided:
1. Are the elements in the collections already sorted?The input collections may or may not be sorted. Don’t assume that they are sorted.
2. Can I sort the elements in the collections? Am I supposed to sort the elements in thecollections?Yes, you can sort the elements in the collections. It is not required that you do so, however..
3. If I sort the collections, should I count the element comparisons that are performed by the sorting algorithm?No. The only element comparisons you should count are the ones that are directly used to find the common elements. Ignore comparisons performed by any sorting algorithms you use.
4. How do I extract an individual collection from the Object[] collections argument of the findCommonElements method?You will need to typecast each collection as type Comparable[]. For example:Comparable[] currentCollection = (Comparable[])collections[i];
5. Why are we using a one-dimensional Object array instead of a two-dimensional array of type Comparable (e.g., Comparable[][])?In Java, arrays are treated as objects, so only a variable of type Object[] can contain arrays. A variable of type Comparable[] can only contain Comparable elements, not arrays. A variable of type Comparable[][] also can only store Comparable elements. Although it is possible to organize the elements such that all the elements at indexes [1][i], for example, are considered to comprise a collection, this is not the same as having an array that contains other arrays. The additional bookkeeping is required to keep a 2D array organized is more complex than simply performing the typecast described above.
6. Can I use other data structures besides arrays; e.g., HashMaps?No. Although it is easier from a programming perspective to use higher order data structures like HashMaps to find common elements, using these structures simply hides the details. If you were to examine the implementations of those structures, you would probably find that they use relatively inefficient algorithms such as sequential searches to find elements. Additionally, if you use library components, you have no way of counting the number of comparisons performed, since you don’t have access to the source code of those components.
7. Is this a trick question? I can’t think of any way to get below NlogN comparisons.It is not a trick question. It is possible to solve this problem using a number of comparisons proportional to (k – 1) * N.
I just want to ask about a kind inheritance.Let say I have an interface MachineCode.I also have different classes, Binary, Hex and Octal that implements MachineCode
Question: How can I prevent java to create an Object like this:
Binary bin = new Binary(); Hex hex = new Hex(); Octal octal = new Octal();
those declaration above must be compile error,
I want to create Objects of Binary, Hex, and Octal this way: MachineCode bin = new Binary(); MachineCode hex = new Hex(); MachineCode octal = new Octal();
I am creating a Guessing game program in java code. I am having an issue with the guess class and main/tester class running. The instructions for the game are The computer generates a random # and the user must guess that number in 7 or fewer guesses. If the guesses exceed 7, then the game is over and the user is asked if they want to 'play again?'These are things I need to incorporate into my code:
If Statement
A Loop of some kind At least three imported methods At least two methods you create Obtains input from the user At least two instance variables At least two local variables Some form of concatenation At least two calculations
import java.util.Random; public class Guess { int computersNumber; // A random number picked by the computer. int usersGuess = 0; // A number entered by user as a guess. int guessCount = 0; // Number of guesses the user has made.
I would like to use java se api names like, undo, redo, stylededitorkit, htmleditorkit in editorpane swing. So, I don't understand how to use these apis.
I have a problem with slider which i want to create jlabels in a panel by sliding the slider and get the value but the jlabel doesn't show in jpanel. Below is the code :
JPanel PanelBoxes; JPanel panel; JLabel c; public static void main(String[] args){ DividePanel div = new DividePanel(); div.go();
I'm trying to create a tile based map JPanel but all I get is a white screen. I'm fairly new to the Java Swing and AWT package so I've been watching tutorials on YouTube so learn as much as I can. I don't know where I'm going wrong.
I've got three classes: Window.java which includes the Main method, Panel.java which is the JPanel and Tile.java to draw all the images into an array.
Window.java:
import javax.swing.JFrame; public class Window extends JFrame { public Window() { setTitle("Project"); setSize(500, 400); setLocationRelativeTo(null);
I'm trying to create java based fairly simple forum.
The task is as following:-
• each user may post exactly one research topic;
• each each may see all research topics posted by other users;
• each each may read all messages contributed by all users on a particular research topic;
• each user may post a new message to contribute to the discussion on any of the topics posted.
Something like below:-
User topic: Intrusion Detection Systems Posted by: John [22/10/11 14:00] John wrote I am building a new IDS based on neural networks. …………….Comments ………….? [22/10/11 14:12] Kate wrote there could be too many false positives!
I've done basic programming in java using Netbeans IDE. So I've good foundational knowledge in java programming. Now I looking forward to draw shapes in java and eventually learn to make simulations. Now I want to learn to create geometric shapes like circle triangle, rectangle etc. I don't know in which Jcomponent(s) should I set the drawing of the shapes, the codes, the libraries and classes I need to import.
I have to write a short quiz that consists of 3 multiple choice questions. When the question is answered wrong I have to get it to loop back and ask the same question until the question is answered right.
I think I have the majority of my variables assigned and I have the scanner set up.
System.out.println("Question 1- Which TV sitcom recently had it's 20th anniversary?"); System.out.println("1. Two and a half men " + question1 + ".Friends 3.The Fresh Prince of Belair h.Get a hint"); answer2 = stdIn.nextInt(); if (answer2 != question1) { System.out.println("Your answer was incorrect, please try again or pick h for a hint"); } else { }
import java.util.Scanner; public class smallestnumber { public static void main(String args[]) { Scanner input=new Scanner(System.in); int smallest =0; int number;
[Code]...
here is the output of my code:
Enter the number 88 Enter the number 8 Enter the number 6 Enter the number 55
What I'm doing about it: googling the shit out of my problems, consulting you fine readers, consulting my friends, and yesterday I signed up for Lynda.com. I'm hoping 30hrs+ or so of watching, rewatching, and analyzing the example code will catch me up before I get too behind in CS302
** Assignment Prompt **
Integer types are very convenient, but their limited width and precision makes them unsuitable for some applications where precision is more important than speed. Develop a class VeryLargeInteger that can handle arbitrary long integer numbers (both negative and positive) and the basic arith- metic operations (addition, subtraction, multiplication, division, and remainder).
Hint: The number could be represented as string, the sign could be represented either as boolean or as part of the string.
Note: Implementations of addition/subtraction through repeated use of a constant incremen- t/decrement will not be accepted. Implementations of multiplication and division that rely only on addition and subtraction will not be accepted.
I know I'm going to have to create a separate tester to call on the VeryLargeInteger class and it's math methods. For the new data type, should I convert the integer/string into an array in order to handle the large length of the number? I know he wants us to use recursion for the math methods. My gut tells me addition and subtraction will be slightly easier than multiplication and division. I know I'll have to reference the other methods for division. We aren't allowed to use the BigInteger class.
How I should construct any of the methods.
Java Code:
import java.util.ArrayList; /** ∗ VeryLargeInteger (VLI) is a class for arbitrary precision integer computation */ public class VeryLargeInteger { private int[] num1; private int[] num2; private int[] num3;
i would like to create a menu like below where if i clicked on "DRAW", a frame to draw will appear and when i clicked on animate, I can animate an object drawn. I tried on using JButton, but I donno how to customize the design n so I would like to know is there other ways so tat my menu will appear as below?