Java Joda Time - download, and install - step by step [closed]

人盡茶涼 提交于 2019-12-17 23:10:22

问题


I've had trouble getting Joda Time to install and work.

Most of the instructions around assume a certain amount of knowledge.

Can someone please assume I know nothing and guide me through, step by step, where to put the Joda Time zip file, do I extract it? How to add it properly using eclipse and how to import it into a class file.

Thanks very much! :)


回答1:


  1. Create your java project in eclipse
  2. Download the latest JodaTime .tar.gz file, and extract its contents
  3. In Eclipse look for your project at package explorer and right click on it then call it New -> Folder -> libs
  4. Copy/Drag joda-time-2.1.jar into the new created libs folder
  5. Right click on your project again (in package explorer) then Properties -> Java Build Path -> Libraries -> Add Jars -> joda-time-2.1.jar
  6. Now you can test with this code :

    DateTime test = new DateTime();

if code compiled ok you are good to go




回答2:


  • Download the zip file
  • Unzip it in a directory of choice
  • Make sure the joda-time-2.1.jar file is in your classpath when you compile and run your program

The classpath is the set of directories and JAR files that Java tools such as the compiler (javac) and the launcher (java) use to find compiled *.class files. See Setting the class path if you don't know how to do that.

For Eclipse: Right-click your project, choose Properties. Select "Java Build Path". Click "Add External JARs...". Select the file joda-time-2.1.jar, click Open, OK.




回答3:


from the docs: http://joda-time.sourceforge.net/installation.html

"The download will contain the joda-time jar file. Once you add this to your classpath you will be able to use Joda-Time."

Which means:

  1. you have to extract the zip file you have downloaded.
  2. it is indifferent, where you put the contents of the zip
  3. you'll have to add the jar file (which were in the zip) to the classpath of the project. In Eclipse: right click on the Project/configure build path/add JAR

Once you have added the JAR to the classpath, you can use it in any class of your own. You'll just have to import the Joda class you are using. e.g.:

import org.joda.time.DateTime;

keep it up




回答4:


  1. Unzip and copy the main jar file somewhere on your machine
  2. Follow these instructions to add the library (jar file) to your project in eclipse
  3. you can start using jodatime, by adding the relevant import statement at the beginning of your class file (or just type DateTime for example, then CTRL+SPACE and eclipse should add the import for you).


来源:https://stackoverflow.com/questions/12105164/java-joda-time-download-and-install-step-by-step

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!