How to integrate PHP and JAVA? - java

I need an urgent help from you people.I got something very odd while trying to integrate php with java. First, my system specifications:
Windows XP
I have installed
XAMPP server:- xampp-win32-1.6.1-installer
This install PHP, Apache, and MySQL on my system. There versions are as follows
Apache Version :- Apache/2.2.4 (Win32)
PHP version :- 4.3.1
Sun Microsystems JDK version :- jdk1.6.0_16
I am achieving this PHP-JAVA extensoion using php-javabridge. I have downloaded javabridge.jar file from following url.
placed the downloaded javabridge.jar file on this path C:\xampp\php\ext\
Settings done in php.ini file for php-java integration are as follows.
; Directory in which the loadable extensions (modules) reside. extension_dir = "C:\xampp\php\ext\"
I also uncomment the java extension.
extension=php_java.dll
I have added following lines in Module Settings section of PHP.ini file.
;;;;;;;;;;;;;;;;;;; ; Module Settings ; ;;;;;;;;;;;;;;;;;;;
[Java] ;This points to the directory where your Java ;classes will be stored. You can designate multiple ;paths, each path separated by a semicolon. ;It must also include the location of php_java.jar java.class.path = "C:\xampp\php\ext\JavaBridge.jar;C:\xampp\php\extensions\php_java.jar;C:\Program Files\Java\jdk1.6.0_16\jre\lib;C:\Program Files\Java\jdk1.6.0_16;C:\prog"
;java.class.path = "C:\xampp\php\extensions\php_java.jar;C:\prog" ; This points to the bin directory of the JDK. java.home = "C:\Program Files\Java\jdk1.6.0_16\bin"
; This must point to the Java Virtual Machine (jvm.dll) file. java.library = "C:\Program Files\Java\jdk1.6.0_16\jre\bin\server\jvm.dll"
; This must point to the location of php_java.dll. java.library.path = "C:\xampp\php\ext;C:\Program Files\Java\jdk1.6.0_16\jre\lib"
java.java = "C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe"
When I start the apache server service, the program runs ok. But, if I close the browser and open it again, the program no longer runs and give me a "Fatal error: Unable to create Java Virtual Machine in C:\php\java.php ...". If I restart the apache server service, the program works again, but with the same behavior: if I close the browser window and open it again, it does not work. I checked on internet but dont get any solution but found many people facing same problem. And many of them told its a bug in PHP-JAVA bridge. So is there any solution on this problem. I ran out of options and, if anyone could help, I'll appreciate.
Thank You.

I tried the Php-JavaBridge recently, by downloading the latest version of Apache, Tomcat and using JDK8.0 and I think Php 5.4 and got it to work totally fine.
Perhaps try downloading the latest version of everything, start from scratch and install again, it may be you have some version mismatches.
I was using a Windows 64 bit computer, running Windows7.

Related

Apache Tomcat will not start on Mac

I cannot get Apache Tomcat to start. I followed the instructions for installing Tomcat on the Mac found at https://www.dev2qa.com/how-to-install-tomcat-in-macos/.
After I type the command to start Tomcat, the response from the command line is that Tomcat has started.
However, when I go to the browser, the default page is not showing up. I further checked to see if the port was being used by using the command
lsof -nP -i4TCP:8080 | grep LISTEN
which showed that no program is using the port. I also read the 'RUNNING.txt' that instructed me on setting the environmental variables, which I did. Any suggestions on why Tomcat is not starting up.
I'm using jdk 1.8.0_202 and Apache Tomcat 9.0.14 that is running of Mac OS High Sierra.
BatChmod
After downloading a fresh version of Tomcat, I use the BatChmod app to alter the file permissions. Tomcat will not launch properly without altering the permissions.
I do not know the command-line equivalent, but here is a screenshot of the settings I have used for years successfully.
Plea for help
If anyone can write the equivalent as a shell script for macOS, please post!
Even better, explain how to wrap such a script as an AppleScript for drag-and-drop execution in Finder.
The problem turned out to be a permissions problem. When I installed Tomcat, I put the folder in the '/Library/Tomcat' directory. Even though the Tomcat files were changed to be executable, the user and group ownership remained the same. To get Tomcat to run, I moved the directory to 'Users/MyUserName/Tomcat'. Once I did that, the default Tomcat page ran.

Running a Java/Selenium program on another computer

I have a small Java program that uses Selenium that I'd like to install on someone else's computer so they can use it too. It uses Selenium (for what it's worth).
I exported from Eclipse to a jar file. I then used launch4j to create a windows executable. I used Java version 1.7_079 to develop the program.
The other computer has JRE version 1.7_079 installed I made sure CLASSPATH is set.
If I run this executable on my system it works fine. If I try and run it on another system nothing happens at all, no errors, no nothing.
What am I doing wrong?
Would it be easier to NOT wrap it in an executable and just use a batch file to run it?
what's the best and easiest way to accomplish this?
Try to execute the .jar directly on the system where it doesn't work by using java.exe/javaw.exe and note the error, if any.
java.exe -jar helloworld.jar
If you get "'java.exe' is not recognized..." you need to add the folder where java/w.exe is to your path (eg: SET PATH=folder-with-java-exes;%PATH%
You can locate java/w.exe files with:
cd /d c:\
dir /S java*.exe
I finally have an answer to this. I traced it down to an issue with Chrome and Chrome driver. I was running Chrome v55.0.x. The users computer was running 57.0.. Once I upgraded my machine to 57. it failed like the users did. I updated Chrome driver and everything works as expected.
you can try this in your code put the path as C:/xxxxxxxx.exe
and put selenuim and the web driver In the C drive and create a jre or exe now .
next step is to ask your client to put selenuim and the web driver also in the C drive in there computers and int will work fine .

How to configure apache tomcat server

I have install jdk1.6.0_04 and I have also install apache-tomcat-8.0.9
and I have set path C:\Program Files (x86)\Java\jdk1.6.0_04\bin;
and CLASSPATH appache tomcat server
C:\Program Files (x86)\apache-tomcat-8.0.9\lib\servlet-api.jar;
but still it's not working properly when i try to open apache tomcat server on web browser
web page is not available
Please guide me the correct way to achieve my objective.
Set JAVA_HOME="C:\Program Files (x86)\Java\jdk1.6.0_04" and CATALINA_HOME="C:\Program Files (x86)\apache-tomcat-8.0.9" than go to %CATALINA_HOME%\bin and run startup.bat
All simple configuration in %CATALINA_HOME%\conf\server.xml
You need jdk1.7 + to run tomcat 8, if you are using jdk1.6, you need tomcat 7-.
See this: http://tomcat.apache.org/whichversion.html
This make me remember back in collage, it took me 2 days to finish jdk/tomcat hello world, :) , what a good time it is.
Just make sure, open a command line, input java --version to check whether you jdk is configured well, and which version it is in use. Just to be sure, in some case you need to re-login or reboot to make your new configured jdk work.
Believe me, if you configured jdk well, you don't need to change anything of the tomcat, just unzip it, and start it, it would work, unless the port 8080 is already taken.
Go to the installation folder of apache tomcat in your case as you said its
C:\Program Files (x86)\apache-tomcat-8.0.9\bin and double click the startup.bat
Then go to web browser and type http://localhost:8080 that should do the work
Set up CATALINE_HOME = your tomcat Location
JAVA_HOME = your java (Version 6 or Seven).
Path = Same JAVA_HOME Java version path til bin.
At final run the startup.bat

ORACLE SQL DEVELOPER,Asking for JDK 7 and NO ADMIN rights

I am trying to use Oracle SQL Developr.
When I try to open it, it asks for the jdk path. Whereas I have only a JRE installed.
I do not have admin privileges and I can not get it that.
I have tried modifying the sqldeveloper\bin\sqldeveloper.CONF file but it did not help.
Is there any alternative to do that.
I have searched for around 3 hours on Google. Nothing hits up straight.
And if you are planning to call it duplicate. I have gone through the similar questions but dint worked out. And installed as per the answer How to start Oracle SQL Developer 4 using 32 bit JDK on Win 64?. But there also ERROR pops up when I start.
I'm assuming you're using the SQL Developer that comes bundled with the Oracle database. IME, it's not worth struggling with that.
I'd recommend using the standalone version instead - it comes with its own JDK, all you need to do is unzip the archive.
UPDATE
Apparently, there's no standalone version of the current SQL Developer 4 for 32bit Windows. But you can use the 3.2.2 release instead.
Copied from this link just for getting it straight to the pointTRIED AND TESTED SOLUTION-With 100 upvotes
As I have tried it and it really works.Posting the solution here.
JDK is not available as a portable zip unfortunately.
However, you can:
Create working JDK directory (C:\JDK in this case)
Download latest version of JDK from oracle (for example jdk-7u7-windows-i586.exe)
Download and install 7-zip (or download 7-zip portable version if you are not administrator)
With 7-zip extract all the files from jdk-[6-7]u?-windows-i586.exe in directory C:\JDK
In command shell (cmd.exe) do the following:
--> change directory to directory C:\JDK\.rsrc\JAVA_CAB10
--> execute command: extrac32 111
Unpack C:\JDK\.rsrc\JAVA_CAB10\tools.zip with 7-zip
In command shell (cmd.exe) do the following:
--> change directory to C:\JDK\.rsrc\JAVA_CAB10\tools\
--> execute command:
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
(this will convert all pack files into jar)
Copy whole directory and all subdir of c:\JDK\.rsrc\JAVA_CAB10\tools where you want your JDK to be and setup manually JAVA_HOME and PATH to point to your JDK dir and its BIN subdir.
Thats all. After this you'll be able at least to use javac.exe

Check if a program is installed on a linux machine from a java applet

Hi I need to be able to check if a certain software is installed on the clients computer and where, in order to launch it. I found the following three posts as to how to do so on Windows and Mac but I can't seem to figure it out for Linux as there is no registry. Does any one know how this can be done on Linux?
Similar posts for Windows and Mac:
Can a Java applet open a "select directory" and write to a filesystem via JavaScript interaction?
read/write to Windows Registry using Java
How can I see the software installed in a Mac OS using a java application?
any help would be greatly appreciated :)
Assuming your security context allows it, you could call out to which.
$ which java
/usr/bin/java
which will output nothing if the program is not found.
Use the
which file
command to find out if the software is installed in the path. If that comes up with nothing then you could do a
find ./ -name "file"
Also check their local bin or .bin if its not included in the path.
Well, basically every binary installed on Linux is in the PATH (environment variable), so if you can find it there, it's there.
There may also be software that installs into other paths, but in this case the user would need to point them out. It is a very uncommon case to have an application in a seperate path and not adding that one to PATH.

Categories