How to build an executable jar in java - java

I am following some guide to build an executable jar.
But I am having a problem, A Java Exception occured.
I tried to run it in cmd.
java.lang.ClassNotFoundException: lc.kra.system.keyboard.GlobalKeyboardHook
I am using 4 external libraries.
mindrot jbcrypt,json simple, geoip2, and keyboard and mouse hook
My Jar file directories are,
here is my imports,
package timer_app;
...
import org.mindrot.jbcrypt.BCrypt;
import lc.kra.system.keyboard.GlobalKeyboardHook;
import lc.kra.system.keyboard.event.GlobalKeyAdapter;
import lc.kra.system.keyboard.event.GlobalKeyEvent;
import lc.kra.system.mouse.GlobalMouseHook;
import lc.kra.system.mouse.event.GlobalMouseAdapter;
import lc.kra.system.mouse.event.GlobalMouseEvent;
import org.json.simple.JSONAware;
import org.json.simple.parser.JSONParser;
import org.json.simple.*;
import java.nio.file.StandardCopyOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
and here is my Manifest file,
Manifest-Version: 1.0
Created-By: 1.8.0_101 (Oracle Corporation)
Main-Class: timer_app.Timer
Class-Path: lib\lib1.jar lib\geoip2-2.8.0-rc1.jar lib\system-hook-2.5.jar
Added cReate jar tool in jcreator.

Place lib1.jar, geoip2-2.8.0-rc1.jar and system-hook-2.5.jar into your lib sub-directory or modify your manifest-file manually to remove the leading lib\ from the path.

jars inside a jar will not be added to the classpath. You have to unjar the thirt Party jars and add the classes only.

Related

Java- Cannot import JIprolog packages

In Java I use these imports:
import com.ugos.jiprolog.engine.JIPEngine;
import com.ugos.jiprolog.engine.JIPQuery;
import com.ugos.jiprolog.engine.JIPSyntaxErrorException;
import com.ugos.jiprolog.engine.JIPTerm;
import com.ugos.jiprolog.engine.JIPTermParser;
And I have downloaded JIProlog and exported it in my project directory.
However when I try to compile my java file (Communicator.java) like this:
javac -cp JIProlog/jipconsole.jar:. Communicator.java
I get an error:
package com.ugos.jiprolog.engine does not exist
Have I skipped a step or something?

Google Analytics API 4 Java client running from command com.google.analyticsreporting.v4 package does not exist

I'm running the API 3 with Java from Windows command using javac and java to compile, no problem. I'm trying the API 4 but can't make even the basic example to run. I understand my problem must be in the classpath but can't pinpoint on the problem. Can't see the com.google packages
I downloaded the API 4 Java Client, copied all .jar in libs to a folder libs in my project. Also copied google-api-services-analyticsreporting-v4-rev110-1.22.0.jar to the libs
I'm testing the service account example as in
https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-java
I setup the compiler as (I know the path exists)
javac -classpath ".;C:\Java\GAnalytics\libs\*" HelloAnalytics4.java
I also tried adding the subdirectories in the client
Error Package does not exit:
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.analyticsreporting.v4.AnalyticsreportingScopes;
import com.google.analyticsreporting.v4.Analyticsreporting;
import com.google.analyticsreporting.v4.model.ColumnHeader;
import com.google.analyticsreporting.v4.model.DateRange;
import com.google.analyticsreporting.v4.model.DateRangeValues;
import com.google.analyticsreporting.v4.model.Dimension;
import com.google.analyticsreporting.v4.model.GetReportsRequest;
import com.google.analyticsreporting.v4.model.GetReportsResponse;
import com.google.analyticsreporting.v4.model.Metric;
import com.google.analyticsreporting.v4.model.MetricHeaderEntry;
import com.google.analyticsreporting.v4.model.Report;
import com.google.analyticsreporting.v4.model.ReportRequest;
import com.google.analyticsreporting.v4.model.ReportRow;
What am I missing?
Same problem for me, I solved by substituting all
"com.google.analyticsreporting.v4" ---> "com.google.api.services.analyticsreporting.v4"
and also:
Analyticsreporting --> AnalyticsReporting
Here the screen of the google-api-services-analyticsreporting-v4-rev111-1.22.0.jar unzipped

StanfordCoreNLP compiler errors using javac

I have just started looking into the Stanford NLP libraries. I downloaded and uncompressed the core file that includes everything, then tried to run the demo file (StanfordCoreNlpDemo.java).
import edu.stanford.nlp.io.*;
import edu.stanford.nlp.ling.*;
import edu.stanford.nlp.pipeline.*;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.util.*;
All of the import lines trigger an "error: package edu.stanford.nlp. does not exist" message.
Can anyone tell me what I need to do to make the demo work?
Include the class path while compiling the core java file by
javac -cp stanford-corenlp-3.5.0.jar filename.java

elasticsearch package import error

I am trying to import following packages in my .java file:-
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
I am getting error that the above mentioned packages do not exist.
You need to download elastic search jar to make it work. Download it from here.
And add it to your classpath.

How to add 3rd party JAR's to compile time classpath in jGRASP?

What do I need to do to successfully the import ij package? I get an error:
ITCN_.java:1: package ij does not exist
The imports are:
import ij.*;
import ij.io.*;
import ij.gui.*;
import ij.process.*;
import ij.measure.*;
import ij.plugin.*;
import ij.plugin.frame.*;
import ij.plugin.filter.PlugInFilter;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.lang.*;
import java.text.*;
I also used Jgrasp back in the day.
I highly recommend moving to eclipse although jGrasp is very simple and works.
To Add to the Build Path you go to Settings -> PATH/CLASSPATH -> Workspace
Click on the "Path" tab, and then the "CLASSPATHS" subtab.
Then Click "New" and where it says Path or Jar file, enter in the path to the ij jar file. Do this for each file if there are more than one.
And then click "apply" and you should be able to use import ij.* and the subsequent functions
It's the ImageJ API. The API docs are available here. You can download it here. Once downloaded, just add the JAR(s) to the compiletime and runtime classpath.

Categories

Resources