Java org.apache.http.ssl.SSLContext not found - java

I am trying to build a HttpClient but can't just figure out how to resolve this ClassNotFound-Error. I installed "org.apache.httpcomponents:httpclient:4.1.3" with maven and several other libraries but yet i won't work.
Code:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.*;
import java.net.URISyntaxException;
import java.util.*;
public class Test {
public static void main(String[] args) {
String bearerToken = "BLABLA";
HttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()).build();
}
}
The corresponding error message:
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/ssl/SSLContexts
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:977)
at Twitter.main(Twitter.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.http.ssl.SSLContexts
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
The maven repos i have installed currently:
oauth.signpost:signpost-commonshttp4:2.0.0
org.json:json:20200518
org.apache.httpcomponents:httpclient:4.1.3
Please note, that i am new to Java and Intellij-IDE.
I appreciate your help.

Try using "httpcore - 4.1.3" (of the same version as of your httpclient jar) jar file. You would be able to import org.apache.http.ssl.SSLContexts successfully.

Is it possible for you to use
org.apache.httpcomponents
httpclient 4.5.2
and then import org.apache.http.conn.ssl.SSLContexts

Related

Java compile error on OSX but not on Windows

I'm running into an issue with Java compile error on OSX but all works fine on Windows 7.
On both platforms I'm using IntelliJ with Java 1.70 u80 SDK and Maven 3.3.9 (bundle from IntelliJ)
The error which appears on OSX is
incompatible types: Iterator cannot be converted to Iterator
for the code line which looks like
Iterator<Node> it = sh.extractAllHeaderElements();
while (it.hasNext())
{
...
}
Any clue why it works on Windows machine but not on Mac?
Edit:
Imports are:
import java.io.*;
import java.lang.management.ManagementFactory;
import java.net.URI;
import java.util.*;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.ServletRequest;
import javax.xml.bind.Element;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nhindirect.xd.soap.type.MetadataLevelEnum;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
The problem appears to be in the Iterator that is being returned with sh.extractAllHeaderElements(); Instead of returning a Iterator<Node> it is returning a Iterator of some other type when run on the mac platform. Thus useing a wildcard with the Iterator interface will work.
To do this just replace the Iterator<Node> it = sh.extractAllHeaderElements(); with Iterator<?> it = sh.extractAllHeaderElements();

Error in Driver class in Java Mapreducer

I get an Error in Handling
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
How to handle it ? Can Anyone please help me...!
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.TextOutputFormat;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
Above are the imported files. And error is occuring in below lines of code.
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
How to fix this issue? I am new to MapReduce.
You are using few packages from updated Hadoop version[mapreduce] but few of them (TextInputFormat & TextOutputFormat) are form older version[mapred package].
It's always good to use packages from map reduce so you have to do below mention change.
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
Refer this : https://github.com/ragnar-lothbrok/hadoop-demo
I have added some working example.
TextInputFormat and TextOutputFormat classes are from different version of hadoop as compared to other classes.Fix the imports for TextInputFormat and TextOutputFormat.

Error initializing class com.jacob.com.Dispatch

I have jacob.jar in the WEB-INF\lib directory and jacob-1.16.1-x86.dll in the windows\system32 directory.
Works ok on a development box. On the production machine it falls over. I am Running Tomcat 7. Log contains:
java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.Dispatch
on this line:
Dispatch oCompy = new Dispatch("Compy.Connect")
Any suggestions?
EDIT:
As per the suggestion I have gone through the source of jacob but I cannot find any import statements that reference a library that would not normally be available. I will include the list here. I am relatively new to Java so maybe I am missing something:
jacob-1.16.1\src\com\jacob\activex\activexcomponent.java - import com.jacob.com.Dispatch;
jacob-1.16.1\src\com\jacob\activex\activexcomponent.java - import com.jacob.com.JacobObject;
jacob-1.16.1\src\com\jacob\activex\activexcomponent.java - import com.jacob.com.Variant;
jacob-1.16.1\src\com\jacob\activex\activexdispatchevents.java - import com.jacob.com.InvocationProxy;
jacob-1.16.1\src\com\jacob\activex\activexdispatchevents.java - import com.jacob.com.Dispatch;
jacob-1.16.1\src\com\jacob\activex\activexdispatchevents.java - import com.jacob.com.DispatchEvents;
jacob-1.16.1\src\com\jacob\activex\activexinvocationproxy.java - import com.jacob.com.Variant;
jacob-1.16.1\src\com\jacob\activex\activexinvocationproxy.java - import com.jacob.com.NotImplementedException;
jacob-1.16.1\src\com\jacob\activex\activexinvocationproxy.java - import java.lang.reflect.Method;
jacob-1.16.1\src\com\jacob\activex\activexinvocationproxy.java - import com.jacob.com.InvocationProxy;
jacob-1.16.1\src\com\jacob\activex\activexinvocationproxy.java - import java.lang.reflect.InvocationTargetException;
jacob-1.16.1\src\com\jacob\com\dateutilities.java - import java.util.Calendar;
jacob-1.16.1\src\com\jacob\com\dateutilities.java - import java.util.Date;
jacob-1.16.1\src\com\jacob\com\invocationproxyallvariants.java - import java.lang.reflect.InvocationTargetException;
jacob-1.16.1\src\com\jacob\com\invocationproxyallvariants.java - import java.lang.reflect.Method;
jacob-1.16.1\src\com\jacob\com\jacobreleaseinfo.java - import java.util.Properties;
jacob-1.16.1\src\com\jacob\com\jacobreleaseinfo.java - import java.io.InputStream;
jacob-1.16.1\src\com\jacob\com\jacobreleaseinfo.java - import java.io.IOException;
jacob-1.16.1\src\com\jacob\com\libraryloader.java - import java.util.Set;
jacob-1.16.1\src\com\jacob\com\libraryloader.java - import java.util.ResourceBundle;
jacob-1.16.1\src\com\jacob\com\libraryloader.java - import java.util.Locale;
jacob-1.16.1\src\com\jacob\com\libraryloader.java - import java.util.MissingResourceException;
jacob-1.16.1\src\com\jacob\com\libraryloader.java - import java.util.Enumeration;
jacob-1.16.1\src\com\jacob\com\libraryloader.java - import java.util.HashSet;
jacob-1.16.1\src\com\jacob\com\rot.java - import java.util.WeakHashMap;
jacob-1.16.1\src\com\jacob\com\rot.java - import java.util.Map;
jacob-1.16.1\src\com\jacob\com\rot.java - import java.util.Iterator;
jacob-1.16.1\src\com\jacob\com\rot.java - import java.util.HashMap;
jacob-1.16.1\src\com\jacob\com\variant.java - import java.util.Date;
jacob-1.16.1\src\com\jacob\com\variant.java - import java.math.BigInteger;
jacob-1.16.1\src\com\jacob\com\variant.java - import java.math.BigDecimal;
jacob-1.16.1\src\com\jacob\com\variantutilities.java - import java.util.Date;
jacob-1.16.1\src\com\jacob\com\variantutilities.java - import java.math.MathContext;
jacob-1.16.1\src\com\jacob\com\variantutilities.java - import java.math.BigDecimal;
jacob-1.16.1\src\com\jacob\com\variantutilities.java - import java.math.BigInteger;
jacob-1.16.1\src\com\jacob\com\variantutilities.java - import java.lang.reflect.Array;
EDIT:
I am not sure if this is actually an answer or not.
I fixed the problem by adding the websites WEB-INF\lib directory to the classpath for Tomcat. I feel that this is not the right answer because my understanding was that a website automatically includes the WEB-INF\lib into the classpath when the site is accessed.
What confuses the issue more is that the site has been running OK accessing other libs in that directory.
Having to add to the classpath is therefore a workaround for a misbehaving library. Which begs the question is a workaround the correct answer?? I guess I will leave the question open.
This error means that the class com.jacob.com.Dispatch is using another class and it can't find it.
If you have the class source code, check to see what classes it uses and see that you have them in your classpath.
If you don't, try to look at the documentation ,find the jar that contains the missing classes and add it to the classpath.

For Java, can I import all packages at once?

For example, the third party library uses very complex directory structure for the package.
Can I import them at once. the star seems can only imports one directory level.
Assuming you're asking whether or not you can do something like:
import com.example.*;
// expecting packages like com.example.foo.* and com.example.bar.* to be imported
Then the answer is no. The widest import you can make is a single package with a star.
The JLS (section 7.5) defines the structure for import statements.
Additionally, it would be problematic for the compiler to import a bunch of packages at once. If two packages provide the same type, both are imported, and the type is used in the class, a compile-time error occurs. This is described in JLS 6.5.5.1:
Otherwise, if a type of that name is
declared by more than one
type-import-on-demand declaration of
the compilation unit, then the name is
ambiguous as a type name; a
compile-time error occurs.
As you pointed in java you can only use "one level" import used by "*"
The more effective way is to open Eclipse, open class where imports should be and press: CTRL + SHIFT + O:) - nowadays all IDE helps with organize imports
I strongly suggest, as others have done, that you use the "organize imports" from your IDE (most major java IDE will do this).
Also, I advice against using "*" in your imports, and the reason for this is simple. At some time, you might want to upgrade one of the library that you import (or the jdk) and you might end up with name clashes due to some new classes in a package (this is especially true for the static imports). It might not be a big deal if that happens to a class inside your current project, but if you make that code into a library at some point, it might be more problematic as you will have to recompile that class after adjusting the conflicting imports.
(Yes, that happened to me not so long ago... It was a pain as I had to hunt down the library source code to rebuild.)
Save yourself some trouble down the road. :D
As others have already said, you can't import all packages at once. However, its not like the end of the world. If you use a good IDE like Intellij, it would add import statements with appropriate package name automatically to your code as soon as you write the code which is using a class/interface from that package.
There is another way if you want to import everything at once. This is not at all recommended but the trick is to go to https://docs.oracle.com/en/java/javase/16/docs/api/allpackages-index.html to check the list of all packages, save that html page on your local system, open the html code. remove all tags from head tag and add this code:
<style>
.block { display: none;}
</style>
After this, save the document and open it in a browser, you'll see the package names clearly without any description. Now, you can just copy-paste them and give them as input to a simple java program that converts them into proper import statements.
The final result is:
import com.sun.jarsigner.*;
import com.sun.java.accessibility.util.*;
import com.sun.jdi.*;
import com.sun.jdi.connect.*;
import com.sun.jdi.connect.spi.*;
import com.sun.jdi.event.*;
import com.sun.jdi.request.*;
import com.sun.management.*;
import com.sun.net.httpserver.*;
import com.sun.net.httpserver.spi.*;
import com.sun.nio.sctp.*;
import com.sun.security.auth.*;
import com.sun.security.auth.callback.*;
import com.sun.security.auth.login.*;
import com.sun.security.auth.module.*;
import com.sun.security.jgss.*;
import com.sun.source.doctree.*;
import com.sun.source.tree.*;
import com.sun.source.util.*;
import com.sun.tools.attach.*;
import com.sun.tools.attach.spi.*;
import com.sun.tools.javac.*;
import com.sun.tools.jconsole.*;
import java.applet.*;
import java.awt.*;
import java.awt.color.*;
import java.awt.datatransfer.*;
import java.awt.desktop.*;
import java.awt.dnd.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.im.*;
import java.awt.im.spi.*;
import java.awt.image.*;
import java.awt.image.renderable.*;
import java.awt.print.*;
import java.beans.*;
import java.beans.beancontext.*;
import java.io.*;
import java.lang.*;
import java.lang.annotation.*;
import java.lang.constant.*;
import java.lang.instrument.*;
import java.lang.invoke.*;
import java.lang.management.*;
import java.lang.module.*;
import java.lang.ref.*;
import java.lang.reflect.*;
import java.math.*;
import java.net.*;
import java.net.http.*;
import java.net.spi.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.nio.charset.*;
import java.nio.charset.spi.*;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.nio.file.spi.*;
import java.rmi.*;
import java.rmi.activation.*;
import java.rmi.dgc.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.security.*;
import java.security.cert.*;
import java.security.interfaces.*;
import java.security.spec.*;
import java.sql.*;
import java.text.*;
import java.text.spi.*;
import java.time.*;
import java.time.chrono.*;
import java.time.format.*;
import java.time.temporal.*;
import java.time.zone.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import java.util.function.*;
import java.util.jar.*;
import java.util.logging.*;
import java.util.prefs.*;
import java.util.regex.*;
import java.util.spi.*;
import java.util.stream.*;
import java.util.zip.*;
import javax.accessibility.*;
import javax.annotation.processing.*;
import javax.crypto.*;
import javax.crypto.interfaces.*;
import javax.crypto.spec.*;
import javax.imageio.*;
import javax.imageio.event.*;
import javax.imageio.metadata.*;
import javax.imageio.plugins.bmp.*;
import javax.imageio.plugins.jpeg.*;
import javax.imageio.plugins.tiff.*;
import javax.imageio.spi.*;
import javax.imageio.stream.*;
import javax.lang.model.*;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
import javax.lang.model.util.*;
import javax.management.*;
import javax.management.loading.*;
import javax.management.modelmbean.*;
import javax.management.monitor.*;
import javax.management.openmbean.*;
import javax.management.relation.*;
import javax.management.remote.*;
import javax.management.remote.rmi.*;
import javax.management.timer.*;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.event.*;
import javax.naming.ldap.*;
import javax.naming.ldap.spi.*;
import javax.naming.spi.*;
import javax.net.*;
import javax.net.ssl.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;
import javax.rmi.ssl.*;
import javax.script.*;
import javax.security.auth.*;
import javax.security.auth.callback.*;
import javax.security.auth.kerberos.*;
import javax.security.auth.login.*;
import javax.security.auth.spi.*;
import javax.security.auth.x500.*;
import javax.security.cert.*;
import javax.security.sasl.*;
import javax.sound.midi.*;
import javax.sound.midi.spi.*;
import javax.sound.sampled.*;
import javax.sound.sampled.spi.*;
import javax.sql.*;
import javax.sql.rowset.*;
import javax.sql.rowset.serial.*;
import javax.sql.rowset.spi.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.colorchooser.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
import javax.swing.plaf.multi.*;
import javax.swing.plaf.nimbus.*;
import javax.swing.plaf.synth.*;
import javax.swing.table.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.text.html.parser.*;
import javax.swing.text.rtf.*;
import javax.swing.tree.*;
import javax.swing.undo.*;
import javax.tools.*;
import javax.transaction.xa.*;
import javax.xml.*;
import javax.xml.catalog.*;
import javax.xml.crypto.*;
import javax.xml.crypto.dom.*;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.dom.*;
import javax.xml.crypto.dsig.keyinfo.*;
import javax.xml.crypto.dsig.spec.*;
import javax.xml.datatype.*;
import javax.xml.namespace.*;
import javax.xml.parsers.*;
import javax.xml.stream.*;
import javax.xml.stream.events.*;
import javax.xml.stream.util.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.sax.*;
import javax.xml.transform.stax.*;
import javax.xml.transform.stream.*;
import javax.xml.validation.*;
import javax.xml.xpath.*;
import jdk.dynalink.*;
import jdk.dynalink.beans.*;
import jdk.dynalink.linker.*;
import jdk.dynalink.linker.support.*;
import jdk.dynalink.support.*;
import jdk.javadoc.doclet.*;
import jdk.jfr.*;
import jdk.jfr.consumer.*;
import jdk.jshell.*;
import jdk.jshell.execution.*;
import jdk.jshell.spi.*;
import jdk.jshell.tool.*;
import jdk.management.jfr.*;
import jdk.net.*;
import jdk.nio.*;
import jdk.security.jarsigner.*;
import netscape.javascript.*;
import org.ietf.jgss.*;
import org.w3c.dom.*;
import org.w3c.dom.bootstrap.*;
import org.w3c.dom.css.*;
import org.w3c.dom.events.*;
import org.w3c.dom.html.*;
import org.w3c.dom.ls.*;
import org.w3c.dom.ranges.*;
import org.w3c.dom.stylesheets.*;
import org.w3c.dom.traversal.*;
import org.w3c.dom.views.*;
import org.w3c.dom.xpath.*;
import org.xml.sax.*;
import org.xml.sax.ext.*;
import org.xml.sax.helpers.*;
You can just copy-paste this to your .java files
Here's the java code that converts the name of packages to import statements:
import java.util.Scanner;
public class import_everything {
public static void main(String[] args) {
String[] s = new String[233];
int i = 0;
Scanner sc = new Scanner(System.in);
while (i < 223) {
s[i] = sc.next();
s[i] = "import " + s[i] + ".*;";
i++;
}
i = 0;
while (i < 223) {
System.out.println(s[i]);
i++;
}
}
}
And here's the list of all the java packages obtained by changing html code of the official documentation provided at https://docs.oracle.com/en/java/javase/16/docs/api/allpackages-index.html :
com.sun.jarsigner
com.sun.java.accessibility.util
com.sun.jdi
com.sun.jdi.connect
com.sun.jdi.connect.spi
com.sun.jdi.event
com.sun.jdi.request
com.sun.management
com.sun.net.httpserver
com.sun.net.httpserver.spi
com.sun.nio.sctp
com.sun.security.auth
com.sun.security.auth.callback
com.sun.security.auth.login
com.sun.security.auth.module
com.sun.security.jgss
com.sun.source.doctree
com.sun.source.tree
com.sun.source.util
com.sun.tools.attach
com.sun.tools.attach.spi
com.sun.tools.javac
com.sun.tools.jconsole
java.applet
java.awt
java.awt.color
java.awt.datatransfer
java.awt.desktop
java.awt.dnd
java.awt.event
java.awt.font
java.awt.geom
java.awt.im
java.awt.im.spi
java.awt.image
java.awt.image.renderable
java.awt.print
java.beans
java.beans.beancontext
java.io
java.lang
java.lang.annotation
java.lang.constant
java.lang.instrument
java.lang.invoke
java.lang.management
java.lang.module
java.lang.ref
java.lang.reflect
java.math
java.net
java.net.http
java.net.spi
java.nio
java.nio.channels
java.nio.channels.spi
java.nio.charset
java.nio.charset.spi
java.nio.file
java.nio.file.attribute
java.nio.file.spi
java.rmi
java.rmi.activation
java.rmi.dgc
java.rmi.registry
java.rmi.server
java.security
java.security.acl
java.security.cert
java.security.interfaces
java.security.spec
java.sql
java.text
java.text.spi
java.time
java.time.chrono
java.time.format
java.time.temporal
java.time.zone
java.util
java.util.concurrent
java.util.concurrent.atomic
java.util.concurrent.locks
java.util.function
java.util.jar
java.util.logging
java.util.prefs
java.util.regex
java.util.spi
java.util.stream
java.util.zip
javax.accessibility
javax.annotation.processing
javax.crypto
javax.crypto.interfaces
javax.crypto.spec
javax.imageio
javax.imageio.event
javax.imageio.metadata
javax.imageio.plugins.bmp
javax.imageio.plugins.jpeg
javax.imageio.plugins.tiff
javax.imageio.spi
javax.imageio.stream
javax.lang.model
javax.lang.model.element
javax.lang.model.type
javax.lang.model.util
javax.management
javax.management.loading
javax.management.modelmbean
javax.management.monitor
javax.management.openmbean
javax.management.relation
javax.management.remote
javax.management.remote.rmi
javax.management.timer
javax.naming
javax.naming.directory
javax.naming.event
javax.naming.ldap
javax.naming.ldap.spi
javax.naming.spi
javax.net
javax.net.ssl
javax.print
javax.print.attribute
javax.print.attribute.standard
javax.print.event
javax.rmi.ssl
javax.script
javax.security.auth
javax.security.auth.callback
javax.security.auth.kerberos
javax.security.auth.login
javax.security.auth.spi
javax.security.auth.x500
javax.security.cert
javax.security.sasl
javax.smartcardio
javax.sound.midi
javax.sound.midi.spi
javax.sound.sampled
javax.sound.sampled.spi
javax.sql
javax.sql.rowset
javax.sql.rowset.serial
javax.sql.rowset.spi
javax.swing
javax.swing.border
javax.swing.colorchooser
javax.swing.event
javax.swing.filechooser
javax.swing.plaf
javax.swing.plaf.basic
javax.swing.plaf.metal
javax.swing.plaf.multi
javax.swing.plaf.nimbus
javax.swing.plaf.synth
javax.swing.table
javax.swing.text
javax.swing.text.html
javax.swing.text.html.parser
javax.swing.text.rtf
javax.swing.tree
javax.swing.undo
javax.tools
javax.transaction.xa
javax.xml
javax.xml.catalog
javax.xml.crypto
javax.xml.crypto.dom
javax.xml.crypto.dsig
javax.xml.crypto.dsig.dom
javax.xml.crypto.dsig.keyinfo
javax.xml.crypto.dsig.spec
javax.xml.datatype
javax.xml.namespace
javax.xml.parsers
javax.xml.stream
javax.xml.stream.events
javax.xml.stream.util
javax.xml.transform
javax.xml.transform.dom
javax.xml.transform.sax
javax.xml.transform.stax
javax.xml.transform.stream
javax.xml.validation
javax.xml.xpath
jdk.dynalink
jdk.dynalink.beans
jdk.dynalink.linker
jdk.dynalink.linker.support
jdk.dynalink.support
jdk.javadoc.doclet
jdk.jfr
jdk.jfr.consumer
jdk.jshell
jdk.jshell.execution
jdk.jshell.spi
jdk.jshell.tool
jdk.management.jfr
jdk.nashorn.api.scripting
jdk.nashorn.api.tree
jdk.net
jdk.nio
jdk.security.jarsigner
netscape.javascript
org.ietf.jgss
org.w3c.dom
org.w3c.dom.bootstrap
org.w3c.dom.css
org.w3c.dom.events
org.w3c.dom.html
org.w3c.dom.ls
org.w3c.dom.ranges
org.w3c.dom.stylesheets
org.w3c.dom.traversal
org.w3c.dom.views
org.w3c.dom.xpath
org.xml.sax
org.xml.sax.ext
org.xml.sax.helpers
just use somthing like
Import java.*
As In the case of JSPs,can I use a .inc file to import all the required classes from 3rd party libraries in a java class
You can import only one directory level.
In IntelliJ Ctrl + Alt + O shortcut can be helpful to:
organize existing imports
remove unneeded imports
add required imports
You can also adjust the auto-import settings under "Settings → Editor → General → Auto Import"
For Basic Usage Only You can use:
import java.*;
import javax.*;
* is for all
java.*;
all classes in java package.

Java & JMF: how do I get the remote IP from a Participant?

I have the participant in an RTP Session, I need to get the IP address from that Participant.
How do I do that?
My imports, by request of one of the answerers:
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.DataSink;
import javax.media.Format;
import javax.media.Manager;
import javax.media.MediaException;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.Processor;
import javax.media.RealizeCompleteEvent;
import javax.media.format.AudioFormat;
import javax.media.protocol.ContentDescriptor;
import javax.media.protocol.DataSource;
import javax.media.rtp.Participant;
import javax.media.rtp.ReceiveStream;
import javax.media.rtp.ReceiveStreamListener;
import javax.media.rtp.SessionAddress;
import javax.media.rtp.SessionListener;
import javax.media.rtp.SessionManager;
import javax.media.rtp.event.NewParticipantEvent;
import javax.media.rtp.event.NewReceiveStreamEvent;
import javax.media.rtp.event.ReceiveStreamEvent;
import javax.media.rtp.event.SessionEvent;
import javax.media.rtp.rtcp.SourceDescription;
when a client connects to RTP server you will get a Socket and can use this method socket.getRemoteSocketAddress().toString(); to find the client IP address. For more detail post sample of your code.

Categories