home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

Java Help

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1510
Discussions: 200,933, Posts: 2,379,168, Members: 246,297
Old October 22nd, 2004, 06:56 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Join Date: Jul 2003
Posts: 1,253
Java Help

I got all these simple little Java programs I have been making, but how do I allow other people to use this? Like how do I make it into an actual program or how can I make it into an applet so people with the plug-in can use it?

I'm using JCreator and making some basic equation solver problems.
Rand Dusing is offline   Reply With Quote
Old October 22nd, 2004, 07:13 PM     #2 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,177
Converting a program into an applet can be pretty easy actually. Depending upon how you set your program up it is sometimes as simple as changing the main method to the init method. You also have to import the correct applet classes.

Wrapping the java classes up into a JAR file also makes it simple for other users to use. If you pack the JAR with the correct commands then it can be executable as well Remember tho they user MUST have the proper JRE! I remember creating a java applet in v1.4 and people with anything lower than the 1.4 JRE could not view it. Just something to think about.
__________________
YAH! I knew you'd be jealous

Last edited by Tekk : October 22nd, 2004 at 07:15 PM.
Tekk is offline   Reply With Quote
Old October 22nd, 2004, 07:37 PM     #3 (permalink)
Member
 
Join Date: Sep 2004
Location: Your living room...
Posts: 417
I would recommend you use Eclipse if you're going to be doing serious development.

If you're just wanting to do something on the command line, I'd first advise using something other than Windows (just a personal bias ). The command you're looking for to "compile" is probably something in the realm of:

javac filename
__________________
I reserve the right to contradict myself. . .
gberz3 is offline   Reply With Quote
Old October 22nd, 2004, 07:40 PM     #4 (permalink)
Ultimate Member
 
Join Date: Jul 2003
Posts: 1,253
Here's a simple program that I made in class for solving the angle using the law of cosine:

//William Rand Dusing
//lawofcosine

import java.text.*;
import java.io.*;

public class lawofcosine

{
public static void main(String[] args) throws IOException

{
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
DecimalFormat output= new DecimalFormat("0.000");

System.out.println("What is the length of one side?");
double side1 = Double.parseDouble(buffer.readLine());

System.out.println("What is the length of the other side?");
double side2 = Double.parseDouble(buffer.readLine());

System.out.println("What is the angle measure in degrees?");
double degrees = Double.parseDouble(buffer.readLine());

double radians = Math.toDegrees(degrees);
double cosradians = Math.cos(radians);
double side3a = (Math.pow(side1,2) + Math.pow(side2,2)) - (2 * (side1) * (side2) * cosradians);
double side3b = Math.sqrt(side3a);

System.out.println();
System.out.println("The side lenght is: " + output.format(side3b));

}

}


What would I do to do what you talked about?
Rand Dusing is offline   Reply With Quote
Old October 22nd, 2004, 07:44 PM     #5 (permalink)
Ultimate Member
 
Join Date: Jul 2003
Posts: 1,253
Where do I run javac filename at? I changed the directory to where the file is located in the Command Prompt but it says javac is an invalid command.
Rand Dusing is offline   Reply With Quote
Old October 22nd, 2004, 07:53 PM     #6 (permalink)
Leader of the Crab People
 
Redwolf's Avatar
 
Join Date: Oct 2001
Location: NCSU
Posts: 4,381
Send a message via ICQ to Redwolf Send a message via AIM to Redwolf Send a message via Yahoo to Redwolf
You have to load your java/bin directory into the path first. Basically, javac compiles the program. If you want to share the file, take the compiled byte code (.class file) and give that out. To run the file, simply type java filename (make sure you DO NOT add the .class extension to the filename). The person has to have the JRE installed for that.

You can write a simple batch to run the byte code. Like:

Code:
@echo off
java lawofcosine
Make sure you follow naming conventions too (as my prof. says, you can hear the sound of your tires getting slashed if you don't). Like lawofcosine would be LawOfCosine.

Last edited by Redwolf : October 22nd, 2004 at 07:56 PM.
Redwolf is offline   Reply With Quote
Old October 22nd, 2004, 07:58 PM     #7 (permalink)
Ultimate Member
 
Join Date: Jul 2003
Posts: 1,253
Oh ok, I already have the files compiled and now I know how to "open" a program. But cant I "compile" that class file into to a more user friendly exe type file? I just want to be able to click a program icon and it pops up the program.
Rand Dusing is offline   Reply With Quote
Old October 22nd, 2004, 08:20 PM     #8 (permalink)
Leader of the Crab People
 
Redwolf's Avatar
 
Join Date: Oct 2001
Location: NCSU
Posts: 4,381
Send a message via ICQ to Redwolf Send a message via AIM to Redwolf Send a message via Yahoo to Redwolf
This is what you need:
http://java.sun.com/docs/books/tutorial/jar/basics/

In a machine with the JRE or SDK, you should be able to double click a .jar file and run it (the icon won't look like an executable though).
Redwolf is offline   Reply With Quote
Old October 22nd, 2004, 09:07 PM     #9 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,177
Theres also a way to set the proper environment variables in windows to always give you access to the java commands (like javac, java, etc) every time a console is opened up (dos prompt). I forget how to properly set these environment variables but maybe someone on here can remind us

Oh and I forgot to mention that JCreator is a nifty little program! Very fast compared to others I have used (Eclipse, JBuilder 8/9/X, NetBeans). I personally prefer JBuilder because it is a little more robust but it is somewhat of a system hog. JBuilder 8 is very robust as well and I used that all through my college Java classes and its not too much of a sys hog (runs perfect on my XP 2000 with 256MB RAM).

Last edited by Tekk : October 22nd, 2004 at 09:10 PM.
Tekk is offline   Reply With Quote
Old October 26th, 2004, 02:23 PM     #10 (permalink)
Member
 
Join Date: Sep 2004
Location: Your living room...
Posts: 417
Quote:
Originally Posted by Tekk
Theres also a way to set the proper environment variables in windows to always give you access to the java commands (like javac, java, etc) every time a console is opened up (dos prompt). I forget how to properly set these environment variables but maybe someone on here can remind us

Yup, in XP you simply right click "MY COMPUTER" -> "PROPERTIES" -> "ADVANCED" tab -> "ENVIRONMENT VARIABLES"
gberz3 is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Opera 7.21 brian0555 Applications and Operating Systems 7 November 2nd, 2003 11:36 AM
Opera ... How come everytime ... Brangwen Applications and Operating Systems 25 January 4th, 2003 09:38 AM
programmers wewtupdawg Applications and Operating Systems 4 August 14th, 2002 02:42 AM
Microsoft Java Virtual Machine Shoes General Tech Discussion 2 August 2nd, 2002 08:07 PM
Re-Installing java -> I.E. Brangwen Applications and Operating Systems 3 July 8th, 2002 01:03 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2875)
Obama the Muslim (14)
California Passes Anti-Flat-HDTV Le.. (39)
Is the PSU I received dead? (10)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
HIS HD5770 graphic card question (15)
Print spooler problem (13)
Foreign voltage (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
Ideal cheap graph card for PC-Gamin.. (17)
EVGA 9800 gtx help with finding a g.. (8)
New Computer wont recognize XP disc (7)
Recent Discussions
Ideal cheap graph card for PC-Gaming? (17)
CPU fan stops spinning randomly (0)
BIOS won't read disk when I try to fl.. (0)
Wireless Televisions. (0)
Install XP pro and a Vista laptop ?? (11)
Partition Magic caused HDD problem (2)
Graphics Card Upgrade Question (1)
favorit (1)
solutions for virtical white lines on.. (1)
Regular Build (3)
Fire in DVD (2)
Modern Warfare For the PC (33)
radeon x850xt platinum & shader 3 (3)
Have you switched yet? (84)
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)
World's largest Monopoly Game using G.. (331)


All times are GMT -4. The time now is 08:44 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28