We have been trying to create JAR files from the LanguageTool (LT) Desktop version we downloaded that contains various JAR files. LT at this link made the statement that we needed all the files in these folders libs org and META-INF in our project. LT has repied they have no experience with Netbeans or JavaFX.
LT Directions
The app was built on Windows 7 with Netbeans 8.2 as a JavaFX 8 and Maven JDK 1.8
We tried following this tutorial the author was not much for proper code formatting and failed to mention that LT is not thread safe. We seldom work with threads but think our code is correct?
TUTORIAL
To install the Class AmericanEnglish.class which is in the LT Desktop zip file we extracted we used this process
cd C:\Users\Me\Documents\A A A A A LT UnZip\LanguageTool-4.7\LanguageTool-4.7
jar cf languagesLIBS.jar libs/*
jar cf languagesORG.jar org/*
jar cf languagesMETA.jar META-INF/*
Here is where it gets odd to our limited knowledge of adding Dependencies to Netbeans
1. Open the Projects tab.
2. Right-click on Dependencies.
3. Select Add dependency.
4. Set groupId to: language(can be anything)
5. Set artifactId to: en (can be anything)
6. Set version to: 4.7(can be anything)
7. Click Add to continue.
Dependency is added to pom.xml and appears under the Libraries node of Maven project. Continue:
1. Expand Dependencies.
2. Right-click on library (e.g., group.id).
3. Select Manually install artifact.
4. Set Artifact to install with the Java Archive (.jar) file path.
5. Click Install locally.
This process did place the AmericanEnglish.class in a JAR and it is found by Netbeans
import org.languagetool.JLanguageTool;
import org.languagetool.language.AmericanEnglish;
import org.languagetool.rules.RuleMatch;
Here is the error when we try to populate the JLanguageTool with AmericanEnglish
While the error NoClassDefFoundError would seem to indicate that the app can not find the
AmericanEnglish.class and that is the cause of the error ClassNotFoundException
Our question obviously is how do we fix this ?
And are we crating the external JAR files correctly?
Exception in thread "Thread-4" java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader
at com.mycompany.maventest.CheckSpellController.lambda$ini$0(CheckSpellController.java:43)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.google.common.cache.CacheLoader
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
We also see these warnings when we Clean and Build the project
The POM for languagetool:LIBS:jar:4.7 is missing, no dependency information available
The POM for languagetool:ORG:jar:4.7 is missing, no dependency information available
The POM for languagetool:META:jar:4.7 is missing, no dependency information available
exec-maven-plugin:1.2.1:exec (unpack-dependencies) # mavenTEST
When the Clean and Build is run we see the dependencies unpack
Here is the few lines of code that cause the error
static JLanguageTool langTool;
public void ini(){
new Thread(() -> {
langTool = new JLanguageTool(new AmericanEnglish());
}).start();
}
The ini() method is called from the initialize method
The necessary JAR files are in the Dependencies folder
The project imports these files
You need to use the actual JAR and the process where you thought it was a bit ODD
Is not the correct way to add JAR files. The extracted ZIP folder has all the gold or should we say JAR's. Here are a few screen shots and directions. That said we are still getting the NoClassDefFoundError so we will work on fixing that part of the question
Delete the three JAR's you added LIBS-4.7.jar META-4.7.jar and ORG-4.7.jar
We would also suggest opening the .m2 folder and under /repository/org/languagetool delete the languagetool folder. Do NOT worry everything will get recreated.
Right Click Dependencies folder and select Add Dependency
In the Query text field enter "org.languagetool"
Here is a comment we did not find languagetool 4.7 JAR's as central only local ? ?
You might like to try and use the central 4.6 JAR's
Expand the org.languagetool:languagetool-core folder and select the 4.7.jar
Once that JAR is in the Dependency folder Right Click ad select Copy Location
Now Right Click the same JAR once more and select Manually Install Artifact
In the Artifact To Install text box paste with a Ctrl + V
This will take you to the location of the JAR select it and presto magic the Artifact is added
Notice the language-en-4.7 we created this JAR file because we could not find AmericanEnglish.class in any of the downloaded files. See Last screen shot
Here are the screen shots in the order to match the above direction
I am not holding my breath that using the downloaded 4.7 JAR,s is the best idea
You might try reaching out to Maven and Language Tool and ask why LT 4.7 is not in the repository!
Best of Luck
Related
Actually, I'm trying to add new language to Streama Media Server. I downloaded source code, added new language file (as guided here). After that, I want to build a jar with that project, I build it with IntelliJ Idea 2021.1 (here is how I did). So, When I run that jar file (in Ubunt 20.04), it fails and gives this error: Screenshot
When you have made adjustments to the source code, it is likely that you will want to create a new .jar file and deploy it on your server. For this, you can use a simple command:
# for unix based systems
**./gradlew assemble**
# for windows
**./gradlew.bat assemble**
This will create 2 new .jar files under build/libs,
streama-{version}.jar
streama-{version}.jar.original
all you will need is the streama-{version}.jar.
This file is an executable, so you can just copy it into your deployment directory / your server and start it as usual.
I am trying to place an updated jar under lib path and removing the old jar. Unfortunately , I see the old logs in oozie console which were present in old jar. For confidential purpose I am unable to show logs here. But I am doing the below steps:
Replacing a jar (mycode.jar) under lib folder which is mentioned in workkflow.xml
Submitted the oozie job using oozie job -oozie http://host -config job.properties -run
When I see logs in console, I could see old jar(older version of mycode.jar) logs even if jar is replaced.
If you are talking about the lib directory in the oozie workflow application then you need not to do anything. The next execution of the workflow will automatically pick the new (updated) jar.
For updating the jars into share lib /user/oozie/share/lib/lib_*/* then after replacing the jar, you need to execute the following command to update the share lib into oozie server.
oozie admin -sharelibupdate
Hope this will help. Thanks.
To make sure issue is same I'll narrate what I was facing:
created a MapReduce JAR and placed it in lib folder.
Ran oozie(MapReduce action) job and picked the JAR as expected and ran fine.
I had some functionality changes in my code(JAR) so I added new log statements to make sure new JAR is being picked. Built the JAR and replaced the old JAR with newly built JAR in lib folder(hdfs)
Ran oozie job again, code from old JAR was executed because new log statements did not show up.
After few search I found following tips:
Clear the Yarn Cache: found this in HortonWorks site(https://community.hortonworks.com/articles/92339/how-to-clear-local-file-cache-and-user-cache-for-y.html) - pasting content below for reference
Short Description:
To use different version jar file with same name, clear cache on all NodeManager hosts to prevent the application using old jar
a. Find out the cache location by checking the value of the yarn.nodemanager.local-dirs property
< property >
< name >yarn.nodemanager.local-dirs< /name>
< value>/hadoop/yarn/local</value>
< /property>
b. Remove filecache and usercache folder located inside the folders that is specified in yarn.nodemanager.local-dirs.
[yarn#node2 ~]$ cd /hadoop/yarn/local/
[yarn#node2 local]$ ls filecache nmPrivate spark_shuffle usercache
[yarn#node2 local]$ rm -rf filecache/ usercache/
c. Restart YARN service.
I was unable to clear cache because I did not have the necessary access. Thus I followed below workaround
Rename the Package or class, since this package/class was written by me, I had the liberty to simply rename the class, thus in oozie when new Class name was looked up, automatically the new functionality was executed.
Option 2 may not be viable for many and the question remains open as to why oozie does not pick New JAR/Class.
I've spent the past week trying to figure this issue out...hopefully someone can help.
I created a Java project that uses MigLayout. I've added the jar file to the same directory where my main class is.
i.e.
java/
Main.java ...contains main() method
MigLayout/miglayout-4.0-swing.jar
It doesn't matter which editor I use, I can compile/run the file and it executes flawlessly.
The issue starts when I try to create a jar file, or compile with cmd. If, for example, in IntelliJ I build the artifact (build the Jar file), it builds it...but it won't run it when I double click on it.
If I use javac in cmd, it gives me this error:
/////////////////////////////////////////////////////////////////////
Main.java:8: error: package net.miginfocom.swing does not exist
import net.miginfocom.swing.MigLayout;
^
Main.java:74: error: cannot find symbol
menuPanel = new JPanel(new MigLayout());
^
symbol: class MigLayout
location: class Main
2 errors
//////////////////////////////////////////////////////////////////////
Any help would be great.
SOLVED
OK, so I got it working. This is what I did:
I created a new folder and moved all of the src files into the src folder there
I made sure to remove all other files that weren't java related, such as the Manifest file
I previously downloaded the MigLayout and json jars and placed them into the src folder as well (that's how I originally got the code to compile)
I opened up IntelliJ and clicked File -> New -> Project from existing source
I selected the folder that contained the src folder
I ran through the prompts. I noticed that it was finding everything: MigLayout and JSON jars
After it was complete, I made sure that it would compile in IntelliJ and it did.
Next, as I did before, I clicked File -> Project Structure -> Artifacts
I clicked the Plus button and selected JAR From Modules with dependencies. I selected the file containing the main method
I checked the Build on make option that's right below the Output directory
I clicked Apply and OK.
Next I clicked Build and Build Artifacts
I selected Jar and Build Jar
Went to the out folder and it was there
I double clicked on it and everything worked!
In the hope of finding the solution on Google as it seems a very general task, I've been trying to do this past few weeks but strangely I couldn't find anything!
What I'm doing:
I am writing an small application, It will be at most a 20KB JAR file in the end. However it has many dependencies, Hibernate and SLF4J to name a few. Directly including these dependencies with the jar file will make it 9Mb.
What is used:
Gradle is used as the build tool. the custom task fatJar creates the jar including all required dependency jar files from (the original) maven repository.
The problem
with my slow internet connection I'd rather not to directly include dependencies, but download these them on the server and not my local production site. What would be the Gradle task like to:
Read the dependencies from jar file
Download them (I know how to do it during Gradle build task).
Add them to class path
Add classpath defined in MANIFEST.mf too
run the jar, by main class defined in MANIFEST.mf
I've read gradle documentation over and over, but no help.
Just downloaded apache commons math 3.3.2 zip (source as opposed to binary) and extracted it. I want to add the jar to classpath in eclipse, but I can't find any file that looks right- only jar is called test. maybe that's it but I was expecting something more like math.commons.3.3.2.jar.
the jar needed is in the binary (rather than source) download
In eclipse, right click your project in the explorer. Click properties, and in the left column click "Javadoc location". Enter the URL "http://commons.apache.org/proper/commons-math/" then it should add all the packages & jars to your project, allowing you to import and reference them with
org.apache.commons.math.(whichever package you would like);