Page 1 of 2 12 LastLast
Results 1 to 20 of 25
Like Tree18Likes

Thread: Java Application for a PHP website

  1. #1
    Join Date
    Dec 2014
    Location
    Iran, Lorestan, Delfan
    Posts
    16
    Rep Power
    0

    Default Java Application for a PHP website

    Hello buddies.
    I have a blog hosting service (like Wordpress) written in PHP and MySQL, I'm gonna make Java Application for it (Runs on Windows, Linux and ...).
    My Questions:
    1. Can I use Connector/J to connect to my website database (MySQL)?
    2. Which one is better? 1.Connect to website database, 2.Use Socket programming.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Java Application for a PHP website

    You are very vague in your intentions. What does this "Java Application" do? Where does PHP come into play?

    1) Yes, as long as the database is reachable from the internet. Default MySQL will bind to 127.0.0.1, so it's not available outside the box it runs on. This is obviously for security reasons. You should really, really, REALLY consider if you are willing to open up the database via internet.
    2) Socket programming is something completely different than using a database. So when connecting to a database, you automatically think "JDBC".

    Reading all this, I assume it's for adding, modifying and deleting content on your blog. You could write a REST API with PHP. Lots of examples are available. This way, you keep your database closed to the world, and you have a generic way of talking to your blog programmatically. You could even develop an Android app for that.
    gimbal2 and miladrahimi93 like this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Java Application for a PHP website

    Well the website is Wordpress, thus PHP. What I don't understand is "I am going to make a java application for it". To do what?
    miladrahimi93 likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Java Application for a PHP website

    Quote Originally Posted by gimbal2 View Post
    Well the website is Wordpress, thus PHP. What I don't understand is "I am going to make a java application for it". To do what?
    No. it's not Wordpress. It's a blog hosting service (like Wordpress) written in PHP.
    miladrahimi93 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Java Application for a PHP website

    Doh, I didn't say anything.
    miladrahimi93 likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Java Application for a PHP website

    Quote Originally Posted by gimbal2 View Post
    Doh, I didn't say anything.
    I share your "to do what" question though. That's where the real answer is.
    miladrahimi93 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  7. #7
    Join Date
    Dec 2014
    Location
    Iran, Lorestan, Delfan
    Posts
    16
    Rep Power
    0

    Default Re: Java Application for a PHP website

    the REST, appreciate it, the key to achieve my goals, thank you!

  8. #8
    Join Date
    Dec 2014
    Location
    Iran, Lorestan, Delfan
    Posts
    16
    Rep Power
    0

    Default Re: Java Application for a PHP website

    Now, How can I implement an application to connect my PHP REST application in Java? Where can I get started?

  9. #9
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,342
    Rep Power
    12

    Default Re: Java Application for a PHP website

    Quote Originally Posted by miladrahimi93 View Post
    Now, How can I implement an application to connect my PHP REST application in Java? Where can I get started?
    There are lots of options for consuming and publishing to ReST services in java. I'm a big fan of Spring Web's RestTemplate Getting Started Consuming a RESTful Web Service since it's pretty straight forward. You can get a bit more formal with https://jax-rs-spec.java.net, but for simple posts and gets to an existing service, it's probably overkill.

    If you're not using Gradle or Maven to manage your dependencies, you really should look into it (I'm a big fan of Gradle since I'm primarily a Groovy developer, but it's equally awesome for java!). You can find spring-web on any of the major maven repos, here is a link: Maven Repository: org.springframework spring-web 4.1.3.RELEASE

    As I mentioned, just add its dependency to your gradle build.gradle or your maven pom file, and away you go!
    miladrahimi93 likes this.

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Java Application for a PHP website

    Quote Originally Posted by quad64bit View Post
    There are lots of options for consuming and publishing to ReST services in java. I'm a big fan of Spring Web's RestTemplate Getting Started Consuming a RESTful Web Service since it's pretty straight forward. You can get a bit more formal with https://jax-rs-spec.java.net, but for simple posts and gets to an existing service, it's probably overkill.
    I don't see how using the basic minimal API is overkill where involving Spring is not...
    miladrahimi93 likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,342
    Rep Power
    12

    Default Re: Java Application for a PHP website

    Quote Originally Posted by gimbal2 View Post
    I don't see how using the basic minimal API is overkill where involving Spring is not...
    Just using RestTemplate from spring web is very light. It's a couple classes in a jar, not a full spring MVC stack or anything. I found Jax RS to be more involved - but to each his own.
    miladrahimi93 and gimbal2 like this.

  12. #12
    Join Date
    Dec 2014
    Location
    Iran, Lorestan, Delfan
    Posts
    16
    Rep Power
    0

    Default Re: Java Application for a PHP website

    Spring or EJB? Which one.
    Last edited by miladrahimi93; 12-29-2014 at 08:40 PM.

  13. #13
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Java Application for a PHP website

    This is going wrong in so many ways. Remember, you are running PHP on the server so you need a PHP REST thing going on the server, and you want a Java client that speaks to the REST API. This has nothing to do wiht EJB's and Spring MVC and what have you...

    Edit: Apparently you can use Spring for the client calls as well... Go for it :)
    Last edited by SurfMan; 12-29-2014 at 09:33 PM.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  14. #14
    Join Date
    Dec 2014
    Location
    Iran, Lorestan, Delfan
    Posts
    16
    Rep Power
    0

    Default Re: Java Application for a PHP website

    I know, it's out of my question. but see: Spring Hello World Example
    A hello world in Spring, WTF? it's just a f**king hello world! Is it real? Gotta repeat all of methods in a XML file?

  15. #15
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Java Application for a PHP website

    Quote Originally Posted by miladrahimi93 View Post
    I know, it's out of my question. but see: Spring Hello World Example
    A hello world in Spring, WTF? it's just a f**king hello world! Is it real? Gotta repeat all of methods in a XML file?
    Before you take off with a rant with no end, this example is using Spring 3.1. The current release of Spring is 4.

    Repeat after me:
    "Before I read a tutorial, I will check two things:
    1) If it's talking about a recent version of the framework/library in question.
    2) If it's NOT on Roseindia.net"

    If both answers are YES, then jog on. If either one is no, please hit CTRL-W and find a new site.
    JosAH and gimbal2 like this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  16. #16
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Java Application for a PHP website

    More proof that basing your entire truth on the internet will just lead you to be a very misinformed programmer who ends up working at Burger King.

    I've said it before and I'll say it again: invest in -quality- sources of information (books, school) and use the piss-poor state of the web as a reference only or to figure out solutions to problems. That last bit I'm adding right here and now and I mean it.
    quad64bit and miladrahimi93 like this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  17. #17
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,342
    Rep Power
    12

    Default Re: Java Application for a PHP website

    Hey guys, this is getting nuts. I was in no way trying to start an enterprise java "this framework vs that framework" pissing contest. My suggestion involved a simple rest client library that *happens* to be made by the spring team. I use it all the time for groovy scripts, as I prefer it to the somewhat convoluted groovy rest builder syntax.

    It also works well for traditional java apps, where I have also used it for both client and server applications which need to consume rest services, and maybe make a post or two, maybe even set some security header values. I'm not advocating EJBs, XML, DAO layers, ORM on big data applications or anything else that is completely irrelevant to the topic at hand, which was: "Now, How can I implement an application to connect my PHP REST application in Java? Where can I get started?".

    A great place to get started is a simple Rest client, which allows you to make GETs and POSTS to some ReST API. I provided a suggestion for that and nothing more. Best of luck!
    miladrahimi93 likes this.

  18. #18
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Java Application for a PHP website

    Why do you feel a need to defend yourself at this point? Nobody is questioning your suggestion - including me, I only questioned the way you sell it. I'm not sorry I did, your retort is perfectly acceptable. Let me like it just to verify that :)

    GROUP HUG!
    miladrahimi93 likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  19. #19
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Java Application for a PHP website

    Quote Originally Posted by gimbal2 View Post
    GROUP HUG!
    Yuck! Maybe you're contaminated with ebola or maybe you haven't taken a shower ...

    kindest regards,

    Jos
    miladrahimi93 likes this.
    Build a wall around Donald Trump; I'll pay for it.

  20. #20
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: Java Application for a PHP website

    Quote Originally Posted by quad64bit View Post
    Hey guys, this is getting nuts.... <snip>
    Remember, in your post YOU didn't mention EJB's, so don't blame yourself. That was the OP that suggested it. That is the nuts part. That, and the ancient Spring version mentioned. New developers still have problems creating the Small Things that, in the end, will form the Big Thing.
    Last edited by SurfMan; 12-31-2014 at 05:24 PM.
    miladrahimi93 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Page 1 of 2 12 LastLast

Similar Threads

  1. Making a facebook like application/website
    By blackz in forum Networking
    Replies: 0
    Last Post: 02-19-2012, 06:35 PM
  2. Replies: 2
    Last Post: 12-31-2011, 04:21 PM
  3. Replies: 4
    Last Post: 07-02-2011, 03:28 AM
  4. java,jsp code to create a website statistics application
    By g.shashikala in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-15-2009, 05:00 PM
  5. How to download website (Get all link in website)
    By finalmem in forum Advanced Java
    Replies: 0
    Last Post: 11-12-2008, 08:43 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •