Solved

Compiling Code

Posted on 1998-05-23
18
188 Views
Last Modified: 2013-11-23
someone please give me a detailed description on how to compile Java code.
and, does anyone have java code that can hide my HTML code?
0
Comment
Question by:Darkmage
  • 9
  • 6
  • 3
18 Comments
 
LVL 1

Accepted Solution

by:
froderik earned 50 total points
ID: 1221395
Compiling Java code:
This depends very much on what platform you ar on. I guess that you are using MS Windows 95/NT. Do you have some tool for developing Java? If you just want to compile JAva you should download JDK from java.sun.com . One of the programs in JDK is called javac and takes a source file as argument and produces a bytecode as output.

Hiding Java code:
I guess you want to have a program that outputs the HTML rather then have it statically on the page. You can do this with a combination of Javascript and Java. From Javascript it is possible to call Java applets which could provide with methods for outputting the desired HTML.

Give me a comment with some more details and I will gladly help you out.
0
 

Author Comment

by:Darkmage
ID: 1221396
I want to have it so when people go to "View page source", they don't see anything


I have Windows 95, and I already downloaded JDK
but I don't understand how to use javac or anything else...
please give me instructions on how to use it

0
 

Expert Comment

by:sdaxm11
ID: 1221397
hmmm. you could use a java Servlet. This allows you to use  java to produce the HTML code. Of course, all they can see is the java.class.
this allows you to also you the GET and  POST methods....  
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Expert Comment

by:froderik
ID: 1221398
I guess the first step then is to make the Java stuff working. So what is your ability in programming. Do you know how to write a Java class? One typical test class could be:

public class Test
{
  public static void main( String[] args )
  {
    System.out.println( "Test output. It works!" );
  }
}

Put the above in a text file and save it as Test.java somewhere. Go to that place on the command line and type "javac Test.java". Your class should now be compiled into Java bytecode and a file called Test.class should appear in the same directory. Then you will have to set the environment variable CLASSPATH to point to the directory with your class files. You can do that with "set CLASSPATH=%CLASSPATH%;.". To run the program type "java Test" and the string you entered in the println method should appear.

Hope this helps.

Fredrik
0
 

Author Comment

by:Darkmage
ID: 1221399
i did that, but when I try to use the .class file on the net, and locally, it doesn't work...the image isn't displayed...
0
 

Expert Comment

by:sdaxm11
ID: 1221400
ok i think the best bet is for you to post the program (either applet or program) so we can have a look.

p.s the example program is a dos based program so the output will be in dos
0
 

Author Comment

by:Darkmage
ID: 1221401
I'll post the code in the next message.....and if possible, somebody could compile it and send it back to me?  =)
0
 

Author Comment

by:Darkmage
ID: 1221402
import java.awt.*;
      import java.applet.*;

      public class ImgApp extends Applet
      {
              Image image;

              public void init()
              {
                      MediaTracker mt = new MediaTracker(this);
                      String img;

                      try {
                              img = getParameter("image");

                              image = getImage(getCodeBase(), img);

                              mt.addImage(image, 0);

                              mt.waitForID(0);

                      } catch (Exception e) {
                              showStatus(e.getMessage());
                      }        
              }

              public void paint(Graphics g)
              {
                      if (image.getWidth(null) > 0) {
                              g.drawImage(image, 0, 0, this);
                      }
              }
      }
0
 

Expert Comment

by:sdaxm11
ID: 1221403
got it to compile,


Êþº¾  - I < > ? @ A B C D
  
  
  
  
  
  
  
  
          
  
     - #  - %  5 '  6 (  7 " 8 ,  9 !  : *  ; )  < 2  G +  H $ ()Ljava/lang/String; ()Ljava/net/URL; ()V (I)V (Ljava/awt/Component;)V (Ljava/awt/Graphics;)V (Ljava/awt/Image;I)V 3(Ljava/awt/Image;IILjava/awt/image/ImageObserver;)Z !(Ljava/awt/image/ImageObserver;)I &(Ljava/lang/String;)Ljava/lang/String; (Ljava/lang/String;)V 2(Ljava/net/URL;Ljava/lang/String;)Ljava/awt/Image; <init> Code ConstantValue
Exceptions LineNumberTable Ljava/awt/Image; LocalVariables
SourceFile addImage       drawImage getCodeBase getImage
getMessage getParameter getWidth image init java/applet/Applet java/awt/Graphics java/awt/Image java/awt/MediaTracker java/lang/Exception java/lang/Throwable out2       out2.java paint
showStatus       waitForID !        < 2     = #  .   z     6» Y*·
L*¶ M***¶ ,¶ µ +*´ ¶ +¶ ±N*-¶ ¶ ±         + ,   1   *
   
                     &  + ,  -  5   F &  .   8     *´ ¶ ž +*´ *¶ W±    1            - #  .        *·       ±    1         4    E

here the class is called out2.class

give me your e-mail if you have problems
0
 

Author Comment

by:Darkmage
ID: 1221404
so did I...I just can't get it to work on the page....
but, send that compiled class code to my e-mail below

darkmage@kayhay.com
0
 

Author Comment

by:Darkmage
ID: 1221405
it works now, but is there any way to make the java conform to the shape of the image?
0
 
LVL 1

Expert Comment

by:froderik
ID: 1221406
I don't get you exactly. If you want the applet to have the same size as the image you can use the method resize in the class Applet for that. And I think that you can get the desired arguments (height and width) from the Image object.
0
 

Author Comment

by:Darkmage
ID: 1221407
that's what I mean, but I'm too lazy to use that for every image....
and I don't think I'll use that now anyways, cause when I use it on a image that is also a link, it won't click
0
 
LVL 1

Expert Comment

by:froderik
ID: 1221408
Sorry for being unclear. My idea was to do it dynamically. Ideal for a lawy developer! Something like this:

import java.awt.*;
           import java.applet.*;

           public class ImgApp extends Applet
           {
                   Image image;

                   public void init()
                   {
                           MediaTracker mt = new MediaTracker(this);
                           String img;

                           try {
                                   img = getParameter("image");

                                   image = getImage(getCodeBase(), img);

                                   int width = image.getWidth( this );
                                   int height = image.getHeight( this );
                                   resize( width, height );
                                   mt.addImage(image, 0);

                                   mt.waitForID(0);

                           } catch (Exception e) {
                                   showStatus(e.getMessage());
                           }        
                   }

                   public void paint(Graphics g)
                   {
                           if (image.getWidth(null) > 0) {
                                   g.drawImage(image, 0, 0, this);
                           }
                   }
           }
0
 

Author Comment

by:Darkmage
ID: 1221409
I tried your code, and using the height and width in PARAM...
but it kept on the same size.....the full width and a certain height...I couldn't adjust

anyone have a solution?
0
 
LVL 1

Expert Comment

by:froderik
ID: 1221410
I think we are getting far away from the original question. It would perhaps be wise to use another question for this matter to attract more experts. This is not exactly my expertise but I will try to help anyway.

Anyway, what does your APPLET tag look like? What happens if you pass some actual numbers to the resize method. Does different numbers give differents sizes of your applet?
0
 

Author Comment

by:Darkmage
ID: 1221411
<APPLET code="ImgApp.class">
<PARAM NAME="image" VALUE="3-d.jpg" HEIGHT=number WIDTH=number>
</APPLET>

that is what I use, where "number" is where I put the dimensions.
when I use that, whatever number I use, it's always the same size. It's about the size of the comment box that you just sent.

and the picture just gets cut off, and there's this ugly gray color that Java gives us in the back. I want the applet to be able to conform around the image, to make it invisble, cause this applet's function is important. I do realize that anyone can just screen grab, look in the HTML source and find the path, but I don't think anyone would be able to think of that.
0
 
LVL 1

Expert Comment

by:froderik
ID: 1221412
You have placed the height and width wrongly. It should look like:
<APPLET code="ImgApp.class" HEIGHT=number WIDTH=number>
      <PARAM NAME="image" VALUE="3-d.jpg" > 
      </APPLET>

I have tried to run your applet but I can't get the resize thing to work. The getWidth and getHeight methods should be after the waitForID method since they can't find the dimensions of the picture unless it is fully loaded. I will see if I can find out where the problem with resize is and get back to you on that. (But as I said in my previous comment, this isn't exactly my area of expertise so another question might solve your problem much faster.)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question