java.lang.NoClassDefFoundError: java.nio.file.FileSystems$DefaultFileSystemHolder - java

Summary:
When I try loading a DLL and the language in my computer is set to a non-latin based language (such as Korean), I get the error java.lang.NoClassDefFoundError: java.nio.file.FileSystems$DefaultFileSystemHolder
If you can help me figure out how to avoid this error, I'd appreciate any help.
I am trying to load a Native DLL Library using:
Native.loadLibrary
But I keep getting these errors:
java.lang.NoClassDefFoundError: java.nio.file.FileSystems$DefaultFileSystemHolder
at java.nio.file.FileSystems.<unknown>(Unknown Source)
at java.io.File.toPath(Unknown Source)
at sun.security.provider.SeedGenerator$1.run(Unknown Source)
at sun.security.provider.SeedGenerator$1.<unknown>(Unknown Source)
at java.security.AccessController.<unknown>(Unknown Source)
at sun.security.provider.SeedGenerator.getSystemEntropy(Unknown Source)
at sun.security.provider.SecureRandom$SeederHolder.<clinit>(Unknown Source)
at sun.security.provider.SecureRandom$SeederHolder.access$100(Unknown Source)
at sun.security.provider.SecureRandom.engineNextBytes(Unknown Source)
at java.security.SecureRandom.nextBytes(Unknown Source)
at java.security.SecureRandom.next(Unknown Source)
at java.util.Random.nextLong(Unknown Source)
at java.io.File$TempDirectory.generateFile(Unknown Source)
at java.io.File.createTempFile(Unknown Source)
at com.sun.jna.Native.extractFromResourcePath(Native.java:839)
at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:751)
at com.sun.jna.Native.loadNativeLibrary(Native.java:737)
at com.sun.jna.Native.<clinit>(Native.java:129)
at com.sun.jna.Native.loadLibrary(RefProp.java:246)
I only get this error when I set my language in my computer to Korean (or any other non-Latin language). When I have it as English, I don't have the error.
By the way, I have set the character encoding as UTF-8:
This code:
Charset charset = Charset.defaultCharset();
System.out.println("Character Set: " + charset.displayName());
Gives this result:
Character Set: UTF-8
So I know the encoding is not the problem.
I've read through:
http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html
OSGi noClassDefFound for java.nio.files.FileSystems$DefaultFileSystemHolder
- Doesn't seem to apply because the error is slightly different.

Related

How count agents from utilities collection with specific characteristic?

There are two types of agents in my Model:
AgentA - it's a parcel which must be delivered to the DeliveryPoint. This AgentA has a corresponding parameter "DeliveryPoint".
AgentB - it's a package (an agent-container) containing parcels (AgentA). This AgentB has a parameter "DeliveryPoint" too that depends on the "DeliveryPoint" of the parcel (AgentA) delivering at the moment.
I need to count agents AgentA in the agent-container AgentB which meet the given condition:
AgentA.DeliveryPoint == AgentB.DeliveryPoint
I tried this expression:
count(agentB.contents(), p -> ((AgentA)agentB.contents()).DeliveryPoint == agentB.DeliveryPoint))
Code example:
private void _movingToDeliveryPoint_onExit_xjal( final com.anylogic.libraries.processmodeling.Delay<AgentB> self, AgentB agent ) {
traceln(count(agent.contents(), p -> ((AgentA)agent.contents()).DeliveryPoint == agent.DeliveryPoint));
}
but when I run my Model, I recieve this error in the block "Delay" ("movingToDeliveryPoint") that executes this code:
java.base/java.util.Collections$UnmodifiableList cannot be cast to smm_chain.AgentA
java.lang.ClassCastException: java.base/java.util.Collections$UnmodifiableList cannot be cast to smm_chain.AgentA
at smm_chain.sc.lambda$0(sc.java:5168)
at com.anylogic.engine.UtilitiesCollection.count(Unknown Source)
at smm_chain.sc._movingToDeliveryPoint_onExit_xjal(sc.java:5168)
at smm_chain.sc.access$25(sc.java:5163)
at smm_chain.sc$17.onExit(sc.java:2319)
at smm_chain.sc$17.onExit(sc.java:1)
at com.anylogic.libraries.processmodeling.Delay.b(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay.b(Unknown Source)
at com.anylogic.libraries.processmodeling.Delay$6.onExit(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBuffer.c(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBuffer.c(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBuffer$1.onExit(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.c(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$1.b(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.InPort.receiveImmediately(Unknown Source)
at com.anylogic.libraries.processmodeling.InputBlock$1.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.a(Unknown Source)
at com.anylogic.libraries.processmodeling.OutputBlock$2.action(Unknown Source)
at com.anylogic.libraries.processmodeling.AsynchronousExecutor_xjal.executeActionOf(Unknown Source)
at com.anylogic.engine.EventTimeout.execute(Unknown Source)
at com.anylogic.engine.Engine.b(Unknown Source)
at com.anylogic.engine.Engine.nb(Unknown Source)
at com.anylogic.engine.Engine.k(Unknown Source)
at com.anylogic.engine.Engine$a.run(Unknown Source)
Could you help me?
Thanks a lot!
You cannot use agentB.contents(). Although it looks like a good method, it is not supposed to be used by modellers.
Also, do not compare objects using ==. Use the equals() method instead.
Do this, assuming you have a population or list named myAgentsA of AgentA within AgentB:
count(myAgentsA, a->a.DeliveryPoint.equals(DeliveryPoint))
This assumes you call the code from within AgentB

This kind of errors in Java Console for an simple Applet

I m trying to run an applet and thats the problems that I take in the Java Console
Java Plug-in 1.6.0_02
Verwendung der JRE-Version 1.6.0_02 Java HotSpot(TM) Client VM
----------------------------------------------------
c: Konsole löschen
f: Objekte in Finalisierungswarteschlange finalisieren
g: Speicherbereinigung
h: Diese Hilfemeldung anzeigen
l: ClassLoader-Liste ausgeben
m: Speicherbelegung anzeigen
o: Protokollierung auslösen
p: Proxy-Konfiguration neu laden
q: Konsole ausblenden
r: Richtlinien-Konfiguration neu laden
s: System- und Bereitstellungseigenschaften ausgeben
t: Threadliste ausgeben
v: Thread-Stack ausgeben
x: ClassLoader-Cache löschen
0-5: Trace-Stufe auf <n> setzen
---- ------------------------------------------------
Laden: Klasse g7appletDialog.class nicht gefunden
java.lang.ClassNotFoundException: g7appletDialog.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Cause d by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
what is the problem? and now I dont know what I have done because I save 10 times directory, there arent any more feedback at the Java concole any more...
g7appletDialog is a bit strange:
The convention for class names is to use an initial capital letter.
The convention is to use packages (directory paths) like de.javamunich.g7applet.MainDialog.
Check the case sensitive correctness of class name and file name. (BTW it is hard to change only the case of a Windows file name in one step.)
Maybe you forgot the package name in HTML?
Start afresh with a new sample applet to have valid examples of how to use codebase and other attributes. It must be something simple.
If you can, extend your question with the HTML code for the applet, and where the .class file resides.

Double click on jar (netbeans built) and nothing happens. Write java -jar from prompt get null pointer exc

I'm quite new to java, so i'm sorry if i'm not noticing some mistake i made.
As the title said, when i build a project which is perfectly running on Netbeans 7.2.1 and then double click on the jar file, nothing happens.
Checking on the web i read it was suggested, in order to spot errors better, to go to the command prompt and write:
java -jar C:\Users\conserva\Documents\NetBeansProjects\EasyText\dist\EasyText.jar
It'gives me this:
C:\>java -jar C:\Users\conserva\Documents\NetBeansProjects\EasyText\dist\EasyText.jar
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at easytext.MainWindow.<init>(MainWindow.java:25)
at easytext.MainWindow$4.run(MainWindow.java:220)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
This is the part of code where line 25 is:
public MainWindow() {
initComponents();
selectfolder.removeAllItems();
String tempordir = ("src/easytext/textfiles/");
String[] arr = new java.io.File(tempordir).list();
/*line 25 */ int len = arr.length;
//System.out.println("arr.lenght è: "+arr.length);
for (int i = 0; i<len; ++i){
selectfolder.addItem(arr[i]);}
selecttext.removeAllItems();
tempordir = ("src/easytext/textfiles/"+selectfolder.getSelectedItem().toString());
arr = new java.io.File(tempordir).list();
for (int i = 0; i<len; ++i){
selecttext.addItem(arr[i]);}
GetText("src/easytext/textfiles/"+selectfolder.getSelectedItem().toString()+"/"+selecttext.getSelectedItem().toString());
}
So it looks like the nullpointerecxeption is thrown as i refer to the lenght of len array.
How can i solve this?
Thanks in advance, and sorry once again if i made some dumb mistake or didn't see something clear. I'm really spending some time on this without getting to a solution.
From the documentation of File.list():
An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
So it sounds like the directory src/easytext/textfiles/ probably doesn't exist from where you're executing the code.

FontFactory (lowagie), Java, getting UnsupportedEncodingException when trying to use UniJIS-UCS2-H (for Japanese)

I am using com.lowagie.text.FontFactory in generating a PDF file and am trying to use a custom font, KozMinPro-Regular, which provides support for Japanese characters, as we have a need to support this. I have found examples from searching that show how to do this similar to how I am doing it below and these examples assume that UniJIS-UCS2-H encoding is supported but when I try this I am getting the exception below that says this encoding is not supported. I would appreciate if anyone may have any insight into this. Thanks
FontFactory.register("/usr/share/fonts/truetype/KozMinPro-Regular.ttf", "JapaneseCompatible");
contentFont = FontFactory.getFont("JapaneseCompatible", "UniJIS-UCS2-H", true, 11, Font.BOLD);
headerFont = FontFactory.getFont("JapaneseCompatible", "UniJIS-UCS2-H", true, 11, Font.BOLD);
The exception I get:
Exception: [.ReportPdfView] Exception caught during generation of pdf file. Cause: UniJIS-UCS2-H
ExceptionConverter: java.io.UnsupportedEncodingException: UniJIS-UCS2-H
at java.lang.StringCoding.encode(StringCoding.java:286)
at java.lang.String.getBytes(String.java:954)
at com.lowagie.text.pdf.PdfEncodings.convertToBytes(Unknown Source)
at com.lowagie.text.pdf.TrueTypeFont.<init>(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.pdf.BaseFont.createFont(Unknown Source)
at com.lowagie.text.FontFactoryImp.getFont(Unknown Source)
at com.lowagie.text.FontFactoryImp.getFont(Unknown Source)
at com.lowagie.text.FontFactory.getFont(Unknown Source)
at com.lowagie.text.FontFactory.getFont(Unknown Source)
You need iTextAsian.jar . It gives CJK support.
see...
http://itextpdf.sourceforge.net/ for earlier versions of iText or
http://sourceforge.net/projects/itext/files/extrajars/ for later version of iText.(extrajars.zip contains iTextAsian.jar)

I need to remove Java Script tags using regular expressions and JRegex

I need to remove all the Java Script tags and the content in between and style tags from the HTML code of web pages.So far I've come up with this expression :
"(<[ \r\n\t]*script([ \r\n\t>]|>){1,}([ \r\n\t]|.)*?</[ \r\n\t]*script[ \r\n\t]*>)|(<[ \r\n\t]*noscript([ \r\n\t>]|>){1,}([ \r\n\t]|.)*?</[ \r\n\t]*noscript[ \r\n\t]*>)|(<[ \r\n\t]*style([ \r\n\t>]|>){1,}([ \r\n\t]|.)*?</[ \r\n\t]*style[ \r\n\t]*>)"
I use JRegex library to work with regular expressions. When I test it in any regex tester it works just fine, but once I run my program - it all crashes down with this error report:
Exception in thread "Thread-0" java.lang.StackOverflowError
at java.util.regex.Pattern$BranchConn.match(Unknown Source)
at java.util.regex.Pattern$BmpCharProperty.match(Unknown Source)
at java.util.regex.Pattern$Branch.match(Unknown Source)
at java.util.regex.Pattern$GroupHead.match(Unknown Source)
at java.util.regex.Pattern$LazyLoop.match(Unknown Source)
at java.util.regex.Pattern$GroupTail.match(Unknown Source)
at java.util.regex.Pattern$BranchConn.match(Unknown Source)
at java.util.regex.Pattern$CharProperty.match(Unknown Source)
at java.util.regex.Pattern$Branch.match(Unknown Source)
at java.util.regex.Pattern$GroupHead.match(Unknown Source)
at java.util.regex.Pattern$LazyLoop.match(Unknown Source)
..................................
And it keeps on going forever. If anyone can give me an advice on this one - I'll be very grateful.
Why not use an HTML parser and just remove the <script> and <style> nodes?
I can resolve this problem. I use a regular expression for remove script tags and the content in between script tags using this regular expression:
#"<(script|SCRIPT)[^+]*?>[^>]*?<(/\script|SCRIPT)>"

Categories

Resources