Search This Blog

Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Tuesday, March 9, 2021

Run Java on .Net - convert java to c#

 must tool to check 

http://www.ikvm.net/index.html

IKVM.NET is an implementation of Java for Mono and the Microsoft .NET Framework. It includes the following components:

  • A Java Virtual Machine implemented in .NET
  • A .NET implementation of the Java class libraries
  • Tools that enable Java and .NET interoperability


i have a jar file with log4j -  i get error 
warning IKVMC0111: Emitted java.lang.NoClassDefFoundError in     ("org.apache.log4j.MDC")
when using 
ikvmc -target:library  123.jar

so :
i download log4j 
convert it to .net dll
ikvmc -target:library log4j-1.2.17.jar

convert 123.jar file to .net dll + add reference to log4j
ikvmc -target:library  123.jar  -r:log4j-1.2.17.dll

and its worked !!!

Happy converting
Yaniv Tzanany

Wednesday, December 25, 2013

web screen scraping tools

HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.
http://htmlunit.sourceforge.net/


tool  http://screen-scraper.com/

java library list http://www.manageability.org/blog/stuff/screen-scraping-tools-written-in-java/view

JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be used as a tool for cleaning up malformed and faulty HTML. In addition, JTidy provides a DOM interface to the document that is being processed, which effectively makes you able to use JTidy as a DOM parser for real-world HTML.
http://jtidy.sourceforge.net/

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.


http://andreas-hess.info/programming/webcrawler/index.html


Monday, July 30, 2012

JNI - get method signature

sometimes when you mixed java and C++ code you must used JNI.
So the best way to find the method signature is via javap application that exist in JAVA jdk.

in case you want to see the method  signature to initialize your jmethodID  follow the next steps:

  1. open command windows
  2. navigate to your class directory (where the class file exist, e.g. c:\xxx\bin\com\)
  3. run the javap.exe -c -s [class name]    ( without the .class e.g. javap -c -s myclass)
make sure your javap is in the PATH , or write the full path to it.

enjoy
Yaniv Tzanany

Tuesday, July 3, 2012

JAVA thread dump on linux

in case you want to see the thread dump of running java process , even the call stack of stuck program.
open new console and run the next command

kill -3 [pid] 

you should see some good info in the console/stdout  of the running process.

Yaniv T

Wednesday, February 22, 2012

JVM COBOL within Apache Tomcat

After installing the micro focus product , we needed to use the Java to Cobol calls.
our java code is running within tomcat 5.5.X via JVM 5.
using microfoucus jar files is not enoght  .. i get the next error

Micro Focus COBOL Runtime Support for Java is preventing this application from executing because an internal Java property is not setup. Reason: Application should use "cobjrun" to execute this application instead of the default "java" trigger

i knew that i need to use cobjrun as my running process and not just java runtime.
based on this article Running JVM COBOL within Apache Tomcat: i started .
in the end i managed to make such call.
the only changes i needed are:

in the file setclasspath.sh .. i changed the _RUNJAVA env .
_RUNJAVA=/opt/microfocus/cobol/bin/cobjrun32

in the file catalina.sh  i add the next env settings

#yaniv add
COBDIR=/opt/microfocus/cobol/
COBJVM=sun_150
LD_LIBRARY_PATH=/opt/microfocus/cobol/lib/:/usr/java/jre/lib/sparc:/usr/java/jre/lib/sparc/client:/usr/java/jre/lib/sparc/native_threads:$LD_LIBRARY_PATH
PATH=/opt/microfocus/cobol/lib/:/usr/java/jre/sh:/usr/java/sh:/usr/java/bin:/usr/java/jre/bin:$PATH
CLASSPATH=/opt/microfocus/cobol/lib/mfcobol.jar:.:/usr/java/jre/lib/rt.jar:/opt/microfocus/cobol/lib/mfimtk.jar:/opt/microfocus/cobol/lib/xerces.jar:/opt/microfocus/cobol/lib/castor-0_9_4_1-xml.jar:/opt/microfocus/cobol/lib/mfcobol.jar:.:/usr/java/jre/lib/rt.jar:/opt/
COBCPY=/opt/microfocus/cobol/cpylib:$COBCPY
export COBDIR
export COBJVM
export LD_LIBRARY_PATH
export PATH
export CLASSPATH
export COBCPY

restart your tomcat .. and enjoy
Yaniv Tzanany

Friday, December 30, 2011

JSOS - servlets office suite (servlets)

Probably the largest collection of
Java(tm) Servlets and filters

Monday, October 10, 2011

Monday, August 1, 2011

Websphere Max memory allocation for JVM

When you set the max memory size on websphere  7 installed on 32 bit machine – you will get the next warning:

 You have set the Maximum heap size field to a value greater than 2 gigabytes. This is only valid on a 64 bit server. You can ignore this warning if the server will run in 64 bit mode; otherwise, the maximum value is 2048.

The server failed to startup on 32 bit machine when I set  the max memory to 2200 (M).
in the startServer.log - you can find such logging:

ADMU7704E: Failed while trying to start the Windows Service associated with server: server1;
probable error executing WASService.exe: Starting Service: YANIVTNode01
Service failed to start.  startServer return code = -1



I test it on 64bit server , I set the max memory to 2500 , and the server startup successfully.
Summary:
If we want more than 2G RAM allocation for websphere on windows  , you must used 64Bit server.

enjoy 
Yaniv Tzanany

Tuesday, July 19, 2011

getting JDBC version

this is the way to get the jdbc extra version


Connection conn = DriverManager.getConnection(connectionString,m_connectionProperties);
DatabaseMetaData dbmd = conn.getMetaData();

   System.out.println("DriverName: " + dbmd.getDriverName() );
   System.out.println("DriverVersion: " + dbmd.getDriverVersion() );
   System.out.println("DriverMajorVersion: " + dbmd.getDriverMajorVersion() );
   System.out.println("DriverMinorVersion: " + dbmd.getDriverMinorVersion() );


how to get the jar file location for specific loaded class

this how to get the jar file location for specific class


   try {
File jarFile = new File(CLASS_NAME.class.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Yaniv T

Sunday, April 3, 2011