Solved

Compiling Code

Posted on 1998-05-23
18
184 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now