Skip to content

Tag: java

Inline comments in Java: /** opposed to /*?

is there a reason i should prefer to write inline-comments in java like this: as opposed to use just one *: Eclipse colours the syntax differently, but is there really anything in the “toolchain” (javadoc, eclipse, etc.) giving me an advantage when using /** */ ? Answer No reason for inline commen…

Connect DB2 with Java

How can I connect DB2 with Java in Eclipse? What are some step-by-step instructions? How can I add the classpath in Eclipse? Code snippet: On running the code, I got the following exceptions: Answer You need to correct the package name. To add .jar in your project, use menu Project → Properties → Java Build P…

Find element position in a Java TreeMap

I am working with a TreeMap of Strings TreeMap<String, String>, and using it to implement a Dictionay of words. I then have a collection of files, and would like to create a representation of each file in the vector space (space of words) defined by the dictionary. Each file should have a vector represe…

How do I update one file in a jar without repackaging the whole jar?

I have a .jar file called myfile.jar. Inside this jar file is a folder called images. Inside this folder called images, I have an image called hi.png. I want to update that image with a new version of that image, which is also called hi.png. I do not want to extract all of the files from the single jar file

Extracting .jar file with command line

I am trying to extract the files from a .jar file. How do I do that using command line? I am running Windows 7 Answer From the docs: To extract the files from a jar file, use x, as in: To extract only certain files from a jar file, supply their filenames: The folder where jar is probably isn’t C:Java

java howto ArrayList push, pop, shift, and unshift

I’ve determined that a Java ArrayList.add is similar to a JavaScript Array.push I’m stuck on finding ArrayList functions similar to the following Array.pop Array.shift Array.unshift I’m leaning toward ArrayList.remove[At] Answer ArrayList is unique in its naming standards. Here are the equiv…

Why can attributes in Java be public?

As everybody knows, Java follows the paradigms of object orientation, where data encapsulation says, that fields (attributes) of an object should be hidden for the outer world and only accessed via methods or that methods are the only interface of the class for the outer world. So why is it possible to declar…

Java Maze shortest path 2d int array

I am currently stuck on a project. My aim is to use Dijkstra’s algorithm. I understand that I start at point (0,0) I look at the two nodes next to the start point and then I move to the smallest first and look at the surrounding nodes. My maze is random but to make it easy to start lets say