Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 19th, 2009, 04:22 PM
spyder0101 spyder0101 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 159 spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 4 h 34 m 17 sec
Reputation Power: 43
Run a Java program from a .exe

Is there any way to get a Java program to execute from a .exe file? I'm trying to package a Java program so that I can just click on it to run it, and more importantly my dad can just click on it to run it. I don't care if it actually compiles the program to machine code (I'm not sure that is possible) or simply hides the details of the execution.

Reply With Quote
  #2  
Old June 19th, 2009, 04:49 PM
Yawmark's Avatar
Yawmark Yawmark is offline
Feelin' Groovy
Click here for more information.
 
Join Date: Aug 2001
Location: WDSMIA
Posts: 9,073 Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level)Yawmark User rank is General 30th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 4 Weeks 1 Day 11 h 8 m 22 sec
Reputation Power: 2975
Send a message via ICQ to Yawmark Send a message via MSN to Yawmark
Google for "executable JAR".

~
Comments on this post
prometheuzz agrees: Indeed, an executable JAR is genrally "better" (easier) than converting to an EXE
__________________
Yawmark
class Sig{public static void main(String...args){\u0066or(int
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}

Reply With Quote
  #3  
Old June 19th, 2009, 05:10 PM
spyder0101 spyder0101 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 159 spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 4 h 34 m 17 sec
Reputation Power: 43
Perfect. Thanks.

Reply With Quote
  #4  
Old June 20th, 2009, 12:11 AM
vaza santosh vaza santosh is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Location: mumbai
Posts: 34 vaza santosh Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 7 m 17 sec
Reputation Power: 0
Wink

see ,it is possible to develop OR convert java .Class files to .exe files .many softwares are available on internet you can easily download them it is fast and easy as they are in very small size. you can use search engins such as "google","wikipedia","yaho".... just you can use"conveting jar to exe" OR "converting .class to exe" you will get result.
i think you new to java programming.
!!!!!! wish you HAPPY PROGRAMMING !!!!!!!!!
Comments on this post
tvc3mye disagrees: There is no point converting the jar file to an exe. If one ever need to do so, it is much better if
you rewrite the thing in C/C++

Reply With Quote
  #5  
Old June 20th, 2009, 12:55 AM
tvc3mye's Avatar
tvc3mye tvc3mye is offline
Daniel Schildsky
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: KL, Malaysia.
Posts: 925 tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)tvc3mye User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 8 m 58 sec
Reputation Power: 495
Send a message via ICQ to tvc3mye Send a message via MSN to tvc3mye Send a message via Yahoo to tvc3mye
Manifest file

Basically it is simply to add a line in the manifest file.

Just add a line in the manifest file like below to make the jar file executable:

Main-Class: <full class name >
__________________
When the programming world turns decent, the real world will turn upside down.

Reply With Quote
  #6  
Old June 20th, 2009, 08:22 AM
prometheuzz prometheuzz is offline
User 165270
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 496 prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level)prometheuzz User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 5 Days 9 h 15 m 23 sec
Reputation Power: 933
Quote:
Originally Posted by tvc3mye
Basically it is simply to add a line in the manifest file.

Just add a line in the manifest file like below to make the jar file executable:

Main-Class: <full class name >


@OP:

... and end with a new line in the manifest file!

More info:
http://www.cs.princeton.edu/introcs...on/jar/jar.html (short)
http://java.sun.com/docs/books/tutorial/deployment/jar/ (thorough)

Reply With Quote
  #7  
Old June 20th, 2009, 08:24 AM
vaza santosh vaza santosh is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Location: mumbai
Posts: 34 vaza santosh Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 9 h 7 m 17 sec
Reputation Power: 0
Cool disagrees

what ever you said is right but what i am saying is that you want a self running programme.
.class-exe OR .jar-.exe converters just pack your class or jar files they onle do is that the execute your class or jar files in exe files.you will always need java runtime environment where ever you use java.
just try it i have tried it numerous times you will get whatever you expect.C C++ is different thing in this.dont merge.
jarto only exe.it will always need jre.

Reply With Quote
  #8  
Old June 26th, 2009, 04:48 PM
spyder0101 spyder0101 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 159 spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level)spyder0101 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 4 h 34 m 17 sec
Reputation Power: 43
Code:
D:\Export Zips>java -jar DrainageNetworkVisualizer2.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/hp/hpl/jena/rdf/m
odel/RDFNode
        at DrainageNetworkVisualizer.main(DrainageNetworkVisualizer.java:33)
Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.rdf.model.RDFNode
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 1 more


This is the error I get when trying to execute it. I've read through the tutorials listed here and a few others but I am still getting the error. It seems that JBuilder is not including the 3rd-party jars when it is packing my jar. How do I get it to include them?

EDIT: It is working now, but I had to add ~50 external jars to the manifest's classpath and package the whole thing into a zip file. Is there any way to distribute that as a single executable .jar?

Last edited by spyder0101 : June 26th, 2009 at 05:24 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Run a Java program from a .exe


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
Stay green...Green IT