Link to home
Start Free TrialLog in
Avatar of Darkmage
Darkmage

asked on

Compiling Code

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?
ASKER CERTIFIED SOLUTION
Avatar of froderik
froderik

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Darkmage
Darkmage

ASKER

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

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....  
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
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...
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
I'll post the code in the next message.....and if possible, somebody could compile it and send it back to me?  =)
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);
                      }
              }
      }
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
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
it works now, but is there any way to make the java conform to the shape of the image?
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.
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
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);
                           }
                   }
           }
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?
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?
<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.
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.)