[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

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?
0
Darkmage
Asked:
Darkmage
  • 9
  • 6
  • 3
1 Solution
 
froderikCommented:
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
 
DarkmageAuthor Commented:
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
 
sdaxm11Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 9
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now