Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java Applet?
Index -> Programming, Java -> Java Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ProgrammingFun




PostPosted: Fri Jan 21, 2011 6:25 pm   Post subject: Java Applet?

Disclaimer: After hours of Googling, I found nothing I understood so I decided to post here...

Is there an easy way to make an applet for a Java program which uses the console as opposed to GUI?
I want to post my Java Culminating here on this website but I do not want to show the source code (because my school might be giving the same project in the future).

Is this even possible?

My program includes one main .java file which also extends to another .java file and reads/writes to .txt files as well.

Thanks for the help. BooHoo
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Fri Jan 21, 2011 6:31 pm   Post subject: Re: Java Applet?

Highly doubt it. The Java console is not owned by your program. If it isn't launched from a console, the console doesn't exist.
Tony




PostPosted: Fri Jan 21, 2011 6:33 pm   Post subject: RE:Java Applet?

How about a compiled JAR?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
ProgrammingFun




PostPosted: Fri Jan 21, 2011 6:33 pm   Post subject: RE:Java Applet?

Is there any way to hide the source code then?

EDIT: How can I compile a JAR?
Insectoid




PostPosted: Fri Jan 21, 2011 7:35 pm   Post subject: RE:Java Applet?

http://java.sun.com/developer/Books/javaprogramming/JAR/basics/
ProgrammingFun




PostPosted: Fri Jan 21, 2011 8:13 pm   Post subject: RE:Java Applet?

Using this: http://java.sun.com/developer/Books/javaprogramming/JAR/basics/build.html

I always get the following error:
Posted Image, might have been reduced in size. Click Image to view fullscreen.
TerranceN




PostPosted: Fri Jan 21, 2011 8:42 pm   Post subject: RE:Java Applet?

Edit your PATH environment variable to include /YOUR_JAVA_SDK_DIRECTORY/bin, then you should be able to use the jar command.
ProgrammingFun




PostPosted: Fri Jan 21, 2011 8:47 pm   Post subject: RE:Java Applet?

Which one is that?

EDIT: When I try to do so, I get the error: "Too much parameters"

I am using instructions from: http://www.skylit.com/javamethods/faqs/createjar.html
Quote:

1. Start Command Prompt.
2. Navigate to the folder that holds your class files:

C:\>cd \mywork

3. Set path to include JDK?s bin. For example:

C:\mywork> path c:\Program Files\Java\jdk1.5.0_09\bin;%path%

4. Compile your class(es):

C:\mywork> javac *.java

5. Create a manifest file:

C:\mywork> echo Main-Class: DanceStudio >manifest.txt

6. Create a jar file:

C:\mywork> jar cvfm DanceStudio.jar manifest.txt *.class

7. Test your jar:

C:\mywork> DanceStudio.jar

Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri Jan 21, 2011 11:11 pm   Post subject: RE:Java Applet?

Your jar line is wrong; the way you specify the m option, the first file specified must be your manifest:

code:
jar cvmf manifest.txt *.class
ProgrammingFun




PostPosted: Sat Jan 22, 2011 1:47 pm   Post subject: RE:Java Applet?

I still get errors. Do I need to import anything into the java files before compiling?
DemonWasp




PostPosted: Sat Jan 22, 2011 3:31 pm   Post subject: RE:Java Applet?

...that's because I ALSO managed to screw up the command line. Sorry. I'll try to get it right this time:

code:
jar cvmf manifest.txt out.jar *.class
ProgrammingFun




PostPosted: Sat Jan 22, 2011 3:50 pm   Post subject: Re: Java Applet?

Since I am so noob, I decided to download and use JCreator to do it for me, BUT:

I get this error from my jar file:
Quote:

Failed to load Main-Class manifest attribute from Othello.jar

I have already included the attribute as follows but I still get the same error:
Quote:

Main-Class: [filename].class


How will the jar file read/write to text files in the root and subfolders?
This is my structure:

Structure:

Culminating
 |
 |- [Main Program].java
 |- Methods.java
 |- [Main Program].class
 |- Methods.class
 |- Instructions.txt (This file is read)
 |---saveData (the saving directory, this is never included into the JAR by JCreator)
      |-[save].txt (read/write)
      |-[more save].txt (read/write)


This is the log that JCreator creates when making the JAR file:
Quote:

--------------------Custom Tool: Create Jar File--------------------
Command : "C:\Program Files\Java\jdk1.6.0_21\bin\jar.exe" cvfm Othello.jar manifest.txt *.class *.txt
Directory : ""

added manifest
adding: Methods.class(in = 14312) (out= 7723)(deflated 46%)
adding: Two_Player_Othello_MuhammadOsama.class(in = 458) (out= 290)(deflated 36%)
adding: Instructions.txt(in = 5082) (out= 1567)(deflated 69%)
adding: manifest.txt(in = 75) (out= 68)(deflated 9%)

Process completed.
TerranceN




PostPosted: Sat Jan 22, 2011 3:58 pm   Post subject: RE:Java Applet?

Does your Manifest.txt end with a newline? It says here, that it must end with a newline or carriage return, otherwise the last command will not be parsed properly.
ProgrammingFun




PostPosted: Sat Jan 22, 2011 4:12 pm   Post subject: RE:Java Applet?

Like this?
Quote:

Class-Path: Othello.jar\r\n
Main-Class: Two_Player_Othello_ProgrammingFun.class\r\n


I still get the same error.
TerranceN




PostPosted: Sat Jan 22, 2011 4:30 pm   Post subject: Re: Java Applet?

First of all, Class-Path is for JAR extensions, from your previous post, I don't think thats what you want. Also, you only use the class name, without the .class, in the manifest file.

No, just put a new empty line, like this
code:

Main-Class: Two_Player_Othello_ProgrammingFun
This line, the last line, will not be parsed, it can be anything.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: