Skip to content

Tag: java

Importing packages in Java

How to import a method from a package into another program? I don’t know how to import… I write a lil’ code: and then, saved it in a folder named “Dan” and I compiled it. The .class file is generated. Then, I wrote this code below: and I saved it outside the folder “Dan&#82…

How can I add files to a Jar file?

I want to add a series of files previously extracted from other files(already done) to a jar. These files will be overwriting files inside the JAR. What is the most efficient way to do it? I need it to be fast. Thank you! Answer A JAR file is a ZIP file, remember. Just use some ZIP library.

How to run a program forever in Java? Is System.in.read() the only way?

I took this code: Does line 33 “System.in.read()” means that it will block until there is input? Will this also work when starting the Java application using UNIX rc script – not manually started from a command line? I’d like to write a Java application to listen for HTTP connections. …

Mongodb avoid duplicate entries

I am newbie to mongodb. May I know how to avoid duplicate entries. In relational tables, we use primary key to avoid it. May I know how to specify it in Mongodb using java? Answer Use an index with the {unique:true} option. You can also do this across multiple fields. See this section in the docs for more det…

Where is jarsigner?

I have the Android SDK installed on both a Linux machine using open SuSE 12.1. I’ve used both machines to successfully build Android apps many times and sign them both with a debug key for testing and a release key from my own keystore, so it should be somewhere on each machine. Using the command Return…