9

I would like to use javax.vecmath in my Java program but unfortunately it says:

The import javax.vecmath cannot be resolved

Should I add the jar by myself in the project? Where can I find that jar file? I'm on Ubuntu/Eclipse Galileo.

Daahrien
  • 10,190
  • 6
  • 39
  • 71
user319869
  • 165
  • 1
  • 1
  • 5

6 Answers6

14

On Ubuntu you can apt-get install libvecmath-java. On other systems do what Petar Minchev suggests, or search on Google for something like "java vecmath", which turns up https://vecmath.dev.java.net/, and then go to their downloads page.

David
  • 15,894
  • 22
  • 55
  • 66
Laurence Gonsalves
  • 137,896
  • 35
  • 246
  • 299
  • How do you get the jar aded to the classpath once you install that? – AJMansfield Sep 12 '13 at 23:42
  • 1
    @AJMansfield run `dpkg -L libvecmath-java` to see where the jar is. For me it's `/usr/share/java/vecmath-1.5.2.jar`. Then just add that jar to your classpath however you normally would (`CLASSPATH` environment variable, IDE settings, `-cp` or `-classpath` command line switch, etc.) – Laurence Gonsalves Sep 13 '13 at 22:16
9

Instead of trying to obtain the file through some OS-dependent package, it would be better to use a dependency manager, for example Maven or Gradle. Using Maven, you could add this dependency to the pom.xml file of your project:

<dependency>
    <groupId>javax.vecmath</groupId>
    <artifactId>vecmath</artifactId>
    <version>1.5.2</version>
</dependency>

See the latest version of the package on Maven Central.


As the top-voted answer suggests, you can get the jar in Ubuntu with:

apt-get install libvecmath-java

And then you can find the location of the jar file with:

dpkg -L libvecmath-java | grep jar$

Which should output something like:

/usr/share/java/vecmath-1.5.2.jar
/usr/share/java/vecmath.jar

It's really just one jar, the file without version is a symbolic link to the other.

To add a jar to the build path in Eclipse (in a non-Maven project):

  1. Right-click on the project
  2. Select Build Path / Add External Archives...
  3. Browse to the jar file and select it

In other operating systems you can download the jar file directly from Maven Central:

https://mvnrepository.com/artifact/javax.vecmath/vecmath/

janos
  • 120,954
  • 29
  • 226
  • 236
3

Search for the vecmath file, you may find it in /usr/share/java.

Copy the contents of this folder to /jdk_installation_folder/jre/lib/ext.

For me, it is /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext.

To copy you can use either the cp-command or change the ext folder permission to 777 using chmod.

$ chmod 777 /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext

Then copy all the files in file explorer.

$ chmod 755 /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext

If you do did not find the vecmath.jar file, then download and install it.

apt-get install libvecmath-java
Nathan
  • 8,093
  • 8
  • 50
  • 76
1

Suggestion#1:

libvecmath-java software package provides javax.vecmath vector math package, you can install in your Ubuntu 17.04 (Zesty Zapus) by running the commands given below on the terminal,

$ sudo apt-get update
$ sudo apt-get install libvecmath-java 

libvecmath-java is installed in your system.

Make ensure the libvecmath-java package were installed using the commands given below,

$ sudo dpkg-query -l | grep libvecmath-java *

You will get with libvecmath-java package name, version, architecture and description in a table.

Resource Link: http://thelinuxfaq.com/ubuntu/ubuntu-17-04-zesty-zapus/libvecmath-java

Suggestion#2:

Open a terminal and install the Java 3D API. This api is also includes vecmath.jar.

sudo apt-get install libjava3d-java

Resource Link:

  1. https://askubuntu.com/a/626128
  2. https://www.howtoinstall.co/en/ubuntu/xenial/libjava3d-java

Suggestion#3:

You can also download the zip, binary or exe from the following oracle link:

  1. http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-java-client-419417.html#java3d-1.5.1-oth-JPR

Suggestion#4:

In eclipse, step by step installation procedure with pictures, is given in the following link:

  1. https://www.cs.utexas.edu/~scottm/cs324e/handouts/setUpJava3dEclipse.htm
SkyWalker
  • 28,384
  • 14
  • 74
  • 132
1

If you are having this issue in an Android project in Android Studio, I had a similar problem and added the following to my dependencies inside of app/build.gradle

implementation 'javax.vecmath:vecmath:1.5.2'
kjanderson2
  • 1,209
  • 12
  • 23
0

Download(updated) the jar and add it to the classpath. In the linked page it is in the "zip binaries", and there in j3d-jre.zip's lib dir.

slashdottir
  • 7,835
  • 7
  • 55
  • 71
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • 3
    The Download link doesn't work! However I found the updated [Download](https://java3d.java.net/binary-builds.html) link! (simply remove the .dev) – reubenjohn Apr 17 '14 at 08:59