Can't update files in jar in vim - java

I had packaged a jar with all dependencies in it by using Maven assembly plugin, after that I want to edit some configuration files enter code here in vim, but I got below errors when I saved.
error (zip#Write) sorry, unable to update /Users/boreas/IdeaProjects/hummi
ngbird/target/hummingbird-1.0-SNAPSHOT-jar-with-dependencies.jar with log4j.xml
How to solve it?

Make sure you have zip and unzip installed (on Ubuntu you'd run sudo apt-get install zip && sudo apt-get install unzip).
Also make sure the file has write permissions for the current user.

Related

Why is OpenJDK 8 not pulling proper JavaFX libraries when using Docker?

I have a java program that I wrote. The main things include OpenJDK8, Maven, and JavaFX. The program builds and runs on its own. I want to put it in a Docker container, but I'm having trouble getting it to build.
Here is my Dockerfile:
FROM openjdk:8-jdk
FROM maven:3.3-jdk-8-onbuild
RUN apt-get update && apt-get install -y --no-install-recommends openjfx && rm -rf /var/lib/apt/lists/*
CMD ["java","-jar","target/"CodeDemo-1.0-SNAPSHOT.jar"]
Here is what I ran to build the container:
sudo docker build -t java-maven-code-demo .
Here is the error I keep getting complaining about no javafxpackager:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
(unpack-dependencies) on project CodeDemo: Command execution failed.
Cannot run program
"/usr/lib/jvm/java-8-openjdk-amd64/jre/../bin/javafxpackager" (in
directory "/usr/src/app"): error=2, No such file or directory -> [Help
1]
I have all the files in a CodeDemo directory. At the top level, I have src, target, Dockerfile, pom.xml. In target, I have the compiled jar.
I'm confused by the error because I thought Java 8 OpenJDK came with JavaFX. So, if I'm pulling OpenJDK, I should be gettng the things I need for JavaFX (similar question on GitHub - solution still gave the error though).
Can anyone point me in the direction of what I could be doing wrong? Is there something else I should be doing to get the proper libraries?
You have multiple FROM lines. Based from your Dockerfile, only the maven base image will be used. Maybe try installing openjdk through another RUN statement before installing openjfx?
I also don't see any COPY statement in your Dockerfile. I initially assumed CodeDemo-1.0-SNAPSHOT.jar exists by default on the maven image but I just tried building the image and it doesn't exist. If that's the jar file from your Java program, don't forget to add it through a COPY statement in your Dockerfile.

Could not find or load main class com.nabinbhandari.lam.Main

I've read a lot of troubleshooting for similar occurrences of this error, but what is causing it for this particular .jar?
https://download.cnet.com/android/nabin-bhandari/3260-20_4-10982661-1.html
It works on Windows, but when attempting to run the file on a raspbian (linux) system running java version 1.8.0_65 with the command java -jar Local\ Area\ Messenger\ Desktop.jar it throws the error about not being able to find or load the main class.
The MANIFEST.MF defines Main-Class: com.nabinbhandari.lam.Main and there doesn't appear to be any issues with case sensitivity.
What am I missing? Do I need to install something more than Java Runtime Environment?
Edit: In case it is not clear, I am not the developer of this file. I am simply a user trying to run the file. This question has nothing to do with Eclipse and I don't understand why people are linking to that other question. I am not running Eclipse. Please stop linking to that. Please examination the .jar file I have provided.
Edit 2: I have followed the instructions and in this answer:
https://stackoverflow.com/a/1238173/2407742
It gives the error no main manifest attribute, in test.jar
Is there something missing from my java runtime environment? It seems like nothing works.
The Local Area Network Messenger application was developed using JavaFX, which is not included in the Oracle Java build for Rasperry Pi. I had to reinstall Java and then openjfx by doing the following:
sudo apt-get purge openjdk-8-jre-headless
sudo apt-get install openjdk-8-jre-headless
sudo apt-get install openjdk-8-jre
sudo apt-get install openjfx
It runs fine now.
The solution to this was the following:
Close Eclipse/STS
Use a file explorer on your operating system to navigate to your workspace (In my case, I'm on Windows so I used Windows Explorer)
Delete the .metadata directory (or to be safe, copy the directory somewhere else to be safe, then delete it)
Restart Eclipse/STS
Is there a more improved answer than this? I don't want to look like I'm trying to boost my own reputation points, so if someone can provide a better answer then please do so.

apt install unable to locate executable

I have read a few other threads similar to this one on stack overflow, but I've been unable to solve my problem.
I am trying to install a package.
apt install libgnutls28-dev
however, I get the following error.
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/apt" (-1)
Other people have been able to solve this error by setting the java home environment variable in the terminal.
export JAVA_HOME=/Library/Java/Home
I have tried this, and then run apt install again, but recieved the same error:
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/apt" (-1)
Any help is appreciated!
Hey I encountered this when trying to install libsndfile. Turns out I was reading their instructions for Debian/Ubuntu. apt isn't a thing on macosx. You'll want to use an alternative package installer like brew.
https://unix.stackexchange.com/questions/359219/error-when-using-apt-on-macos-sierra
export JAVA_HOME should point to the directory where the JDK or JRE is installed.
JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::") in a console or directly in .bashrc should do the trick under debian

Why can't I install Eclipse?

I am trying to install Eclipse.
> desktop-file-install eclipse.desktop
> Error on file "eclipse.desktop": Key file does not start with a group
>Name=Eclipse
>Type=Application
>Exec=/opt/eclipse/eclipse
>Terminal=false
>Icon=/opt/eclipse/icon.xpm
>Comment=Integrated Development Environment
>NoDisplay=false
>Categories=Development;IDE;
>Name[en]=Eclipse
What is wrong?
My Ubuntu version is 10.04 but I do not know if that plays any role here.
You need to add
[Desktop Entry]
to the top of your file--it's the group name that command is looking for.
See here for more information about desktop entries.
In order to install Eclipse you only need to have a working JDK installation and the unzip the eclipse bundle and finally execute eclipse.
To install OpenJDK from ubuntu repositories you can do this.
sudo apt-get install openjdk-6-jdk
OpenJDK7 does not seem to be in 10.04 repositories.
You can always install Oracle JDK manually but perhaps you should think about upgrading you ubuntu installation to the latest LTS release.
Try This option.
change permission for eclipse dir sudo chmode -R 755 -R /opt/eclipse.
Java Home
open gedit /home/[user]/.bashrc
Add that two line at the end .
export JAVA_HOME=/path/to/jdk1.(xx version)
export PATH=$PATH:$JAVA_HOME:$JAVA_HOME/bin
Update
As mentioned by #Allison
You need to add [Desktop Entry]

Import javax.vecmath

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.
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.
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):
Right-click on the project
Select Build Path / Add External Archives...
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/
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
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:
https://askubuntu.com/a/626128
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:
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:
https://www.cs.utexas.edu/~scottm/cs324e/handouts/setUpJava3dEclipse.htm
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'
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.

Categories

Resources