Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Stand Alone Classes

  1. #1
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    Location
    San Pedro Sula, Honduras
    Posts
    58
    My Mood
    Inspired
    Thanks
    11
    Thanked 1 Time in 1 Post

    Lightbulb Stand Alone Classes

    Hello forums,

    Great Sunday ins't it?

    So I've been working on a personal project. So far I've got a program that can create other individual stand alone programs (.java & .class) at any given location. I would like to double check on something. Since java is sending instructions to shell or cmd prompt, every time a new class is executed, we could say they are in their own independer runtime.

    Is that correct?


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Stand Alone Classes

    Yes.

  3. #3
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    Location
    San Pedro Sula, Honduras
    Posts
    58
    My Mood
    Inspired
    Thanks
    11
    Thanked 1 Time in 1 Post

    Question Re: Stand Alone Classes

    Sup, helloworld922,

    While I have you here I'd like to know something. Java's got writers and readers for files, streams, strings, and all. I know that the class files are the ones executed, but is it posible for the class to read itself?

    Our code always starts with:
    public static void main(String... args) {
     
    }

    The args represents everything within the { }. I think I've heard the is a way to read whats in between { } and interpret or return a String instead of executing any of the instructions?

    If so, do you have any idea on how to acomplish it? Any hint?

    I found a similar question in the forums http://www.javaprogrammingforums.com...in-itself.html

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Stand Alone Classes

    args does not represent what's between the brackets.

    args is the parameters which are passed to the program from the command-line:

    java some_class arg1 arg2

    I hope that's the correct syntax, if not you get the idea.

    args will now contain 2 String objects: "arg1", and "arg2".

    I'm unaware of any way to extract the source from inside a method without the original source code, and even that can get dicey because you'll need to be able to correctly parse the Java code.

  5. #5
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    Location
    San Pedro Sula, Honduras
    Posts
    58
    My Mood
    Inspired
    Thanks
    11
    Thanked 1 Time in 1 Post

    Default Re: Stand Alone Classes

    Too complicated I guess.

    What I am trying to achieve is for this program to create itself again (at some point of my project I'll add logic so that code would not always be the same but differentiates from the original), in addition of the code that makes a .java compilable.

    I thought there was a more elegant way, but I guess I'll just have emuns type String containing java code.

Similar Threads

  1. How to make an Eclipse program stand alone and more
    By TheBigWif in forum Java Theory & Questions
    Replies: 3
    Last Post: July 30th, 2013, 05:35 PM
  2. fetch HTML page content from the web ( by executing javascript ) using stand alone
    By johnyabu@gmail.com in forum Java Theory & Questions
    Replies: 7
    Last Post: February 8th, 2011, 07:25 AM
  3. Replies: 2
    Last Post: October 14th, 2009, 10:10 AM
  4. Replies: 8
    Last Post: August 6th, 2009, 01:35 PM