Results 1 to 7 of 7
  1. #1
    Ruben.cc is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default Include (and run) uncompiled Java

    Here's a totally noob question so all you Java experts can have a good laugh...

    I'm totally new to Java and like to learn it the way I also learned other languages, like PHP for example, by just "change things and see what happens". I have a nice Java app currently included on my site I want to tweak and change. It's a JAR file, which I understand is a Java ARchive. My default archiving software opens it without problems and inside are compiled Java files. Can't edit those, but I also have all the individual source files.

    Now my question; does Java embedded in sites need to be compiled and archived to function?

    Most ideally I would like to put the raw .java source online and be able to edit and run it from my web server. I'm already guessing that is not gonna work. So my second best "wish" is to have all the separate compiled elements on my web server so I don't need to recompile every single bit and upload the entire JAR again.

    Or alternatively; can I somehow have the compiling done by my web server?

    I hope you guys get the general idea; I just want to mess around with the Java app on my site without to much hassle of constantly recompiling and JARring stuff.

    What are my options?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default

    java is a compiled language. The compiler creates byte code for the source and writes it to a .class file. The class files are gathered together in a jar file for ease of use.
    You make changes to the source, compile it and then execute it with an interpreter that either turns the byte code into executeable or interprets it.

    PHP is interpreted directly from its source.

  3. #3
    cultclassic is offline Member
    Join Date
    Mar 2011
    Posts
    64
    Rep Power
    0

    Default

    Quote Originally Posted by Ruben.cc View Post
    So my second best "wish" is to have all the separate compiled elements on my web server so I don't need to recompile every single bit and upload the entire JAR again.
    Java code on a web page does NOT have to be on a jar file. The files can stay in as class files. Unzip the class files in the jar file to the directory (keeping the class directory intact) where the html file is located. You wont have to create new jar file every time you change java code. You will need to compile the java file though.

    Quote Originally Posted by Ruben.cc View Post
    Or alternatively; can I somehow have the compiling done by my web server?
    Yes. Google "Java Server Pages" (JSP). This wouldn't exactly be "object oriented" programming, but you can get familiar with language syntax. Compiling java files is the way to go though.
    JSP Tutorial
    Last edited by cultclassic; 05-17-2011 at 08:05 PM.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Hopefully you don't mean that he should be using scriptlets in those JSPs, however.

  5. #5
    Ruben.cc is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default

    Wow, thanks for the fast replies guys! Just had a cup of coffee and a smoke and already there is mail about replies! :-)

    I understand that Java is executed client side as opposed to PHP server side. I didn't mean that I would actually run the Java on my server, but be able to edit it there. I have three computers in three different locations I use on a regular basis so I try to keep as much stuff on my server as I can. Also I would like to enable a friend to participate in the "messing around" with the Java code.

    So the general idea is/was to be able to just edit the code online using one of my editors running under PHP that does all the nice code colouring and stuff and then see what happens when you run it on/in your browser. So even though the code is executed inside the client browser I would still love to have the source online so I don't have three different sources on three different location or need to drag around an USB stick and have the necessary editors on all computers.

    But your answers made it clear that it needs to be at least compiler. Too bad, but the idea of keeping all the single class files on the server instead of the entire JAR file is still a good option also. That way my friend and I could at least mess around with different parts of the code and each update those files individually. There's a total of 35 class files to play around with.

    I'll take a look at the JSP thing later.

    Thanks for the answers!

  6. #6
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    No, the java is also executed server-side unless you are talking about a "web service" application or applet, which is something else again.

    There are ways of doing it (Java has a Compiler class and you could also call javac from a php/perl/whatever script or some other servlet type program such as ASP), if you know nothing about Java, however (which your posts indicate), then this, currently, is way beyond you.

    (Edit: Server-side if you are talking about web sites and enterprise applications, client-side for "web-service", applet, and standalone appliactions, however.)
    Last edited by masijade; 05-17-2011 at 08:15 PM.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,587
    Rep Power
    25

    Default

    If your handy with PHP, you could probably write some code in PHP to compile a .java file on the server and send you the console with results. You'd also need download and upload capability to be able to edit the source.

Similar Threads

  1. Replies: 0
    Last Post: 03-02-2010, 09:28 AM
  2. include-prelude/include-coda
    By devin in forum Java Servlet
    Replies: 0
    Last Post: 02-11-2009, 08:33 PM
  3. Replies: 5
    Last Post: 07-29-2008, 03:13 PM
  4. Include Java file in HTML Page
    By kathyc in forum New To Java
    Replies: 2
    Last Post: 03-07-2008, 04:51 AM
  5. jsp:include and include file
    By Heather in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-14-2007, 05:19 PM

Posting Permissions

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